HW agent API 2.14.1

API section

Device port

Raw byte exchange with a device port from the list (COM, TCP, HID): send and read the answer.

POST/api/v1/channels/{id}/exchangeSend bytes to the port and get the reply

Send bytes to the port and get the reply#

POST/api/v1/channels/{id}/exchange

Only for ports added on the setup page (kind “Device port”). Immediate, not an operation

Parameters

NameInTypeDescription
idrequiredpathinteger int32

device number from GET /api/v1/devices

Request body application/json required

Fields · ExchangeRequest
  • hexstring
  • base64string
  • textstring
  • charsetstring
  • readTimeoutMsinteger int32
    from 0
    to 60000
  • maxBytesinteger int32
    from 1
    to 65536
  • untilstring
  • startstring
  • lengthinteger int32
    from 1
  • lengthOffsetinteger int32
    from 0
  • lengthBytesinteger int32
  • lengthAdjustinteger int32
  • crcstring
  • crcSkipinteger int32
    from 0
JSON
{
  "hex": "string",
  "base64": "string",
  "text": "string",
  "charset": "string",
  "readTimeoutMs": 0,
  "maxBytes": 1,
  "until": "string",
  "start": "string",
  "length": 1,
  "lengthOffset": 0,
  "lengthBytes": 1,
  "lengthAdjust": 1,
  "crc": "string",
  "crcSkip": 0
}

Response 200 application/json

Fields · ExchangeResult
  • bytesinteger int32
  • hexstring
  • base64string
  • textstring
  • crcValidboolean

Errors — problem+json with a code field, see error codes.

Request example

curl
curl -X POST 'http://localhost:7790/api/v1/channels/1/exchange' \
  -H 'Content-Type: application/json' \
  --data '{"hex":"string","base64":"string","text":"string","charset":"string","readTimeoutMs":0,"maxBytes":1,"until":"string","start":"string","length":1,"lengthOffset":0,"lengthBytes":1,"lengthAdjust":1,"crc":"string","crcSkip":0}'
curl
curl -X POST 'https://cloud.hw-connector.ru/agent/api/v1/channels/1/exchange' \
  -H 'X-Api-Key: hwk_…' \
  -H 'X-Device-Id: 42' \
  -H 'Content-Type: application/json' \
  --data '{"hex":"string","base64":"string","text":"string","charset":"string","readTimeoutMs":0,"maxBytes":1,"until":"string","start":"string","length":1,"lengthOffset":0,"lengthBytes":1,"lengthAdjust":1,"crc":"string","crcSkip":0}'