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}/exchange | Send bytes to the port and get the reply |
Send bytes to the port and get the reply#
POST
/api/v1/channels/{id}/exchangeOnly for ports added on the setup page (kind “Device port”). Immediate, not an operation
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | integer int32 | device number from |
Request body application/json required
Fields · ExchangeRequest
hexstringbase64stringtextstringcharsetstringreadTimeoutMsinteger int32from 0to 60000maxBytesinteger int32from 1to 65536untilstringstartstringlengthinteger int32from 1lengthOffsetinteger int32from 0lengthBytesinteger int32lengthAdjustinteger int32crcstringcrcSkipinteger int32from 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 int32hexstringbase64stringtextstringcrcValidboolean
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}'