The following sections describe the JSON (JavaScript Object Notation) data-interchange syntax to read/write printer settings.
Note that the SettingsReadWrite class provides support to read/write settings and uses the JSON command structure defined below to communicate with printer. This is provided as information for anyone that would like to communicate directly with the printer using the JSON interface supported by the printer.
General JSON Command Syntax - Management Port
The following is the general syntax for JSON commands to printer.
Note that the To and From keys are optional and can be left out if the application does not require it. These parameters simply get swapped and echoed back from the printer.
The printer responds to a command with an echoed TrackNo that was sent that can be used by the caller/sender to select the appropriate response from the printer for cases where multiple commands are sent to printer. If data is sent back by printer, it is part of the Content field.
Full command.
{ "Command": <command>,
"From": <optional>,
"To": <optional>,
"TrackNo": <AnyTrackingString>,
"Content": { <content> }
}
Minimum command. No To or From optional keys.
{ "Command": <command>,
"TrackNo": <AnyTrackingString>,
"Content": { <content> }
}
Supported JSON Commands
The following are supported values for "Command" key sent to printer.
- "Cfg.Item" read/write key/value pair(s)
- Read key(s) item by using null as value.
- Read Single Key.
("Content":) { "MyKeyOfInterest" : null }
- Read Multiple Keys.
("Content":)
{ "MyKey1" : null, "MyKey2" : null, .., "MyKeyN" : null }
- Note that multiple keys can be read if a branch name is used.
e.g. using "branchX.subBranch" as key will return both key "item1" and "item2" if branchX.subBranch.item1 and branchX.subBranch.item2 exists.
("Content":): { "branchX.subBranch" : null }
- Write key(s) by using any supported value associated with specific key.
("Content":):
- "Cfg.Prop" reads properties associated with key(s) or branch
- Properties:
Property | Description |
"Type" | "Dec" - Decimal, "Enum" - Enumeration, "Bool" - Boolean, "Exe" - Executable |
"Perm" | Permision: Read (R), Write (W), Execute (X) |
"Value" | The current value associated with key |
"Min" | Minimum value |
"Max" | Maximum value |
"Inc" | Increment |
"Options" | The allowed values. Note for Bool only true or false allowed. |
- Properties returned by key "Type":
| "Dec" | "Enum" | "Bool" | "Exe" |
"Type" | x | x | x | x |
"Perm" | x | x | x | x |
"Value" | x | x | x | |
"Min" | x | | | |
"Max" | x | | | |
"Inc" | x | | | |
"Options" | | x | | |
Supported JSON Keys
Supported key/value pairs:
Examples
Example 1 - Read "Image.Width-in" key
{ "Command": "Cfg.Item",
"TrackNo": "Ex-1",
"Content": {
"Image.Width-in" : null
}
}
Example 2 - Write "Image.Width-in" key
{ "Command": "Cfg.Item",
"TrackNo": "Ex-2",
"Content": {
"Image.Width-in" : 3.5
}
}
Example 3 - Read Properties for multiple keys
Below shows how to read multiple "branch" items ("Speed" and "ODV.Symbol") in order to read all keys associated with each branch as well as an individual item "Label.Sensor".
Command Sent To Printer:
{ "Command": "Cfg.Prop",
"From": "Originator",
"To": "Receiver101",
"TrackNo": "Ex-3",
"Content": {
"Speed" : null,
"ODV.Symbol" : null,
"Label.Sensor":null
}
}
Printer Response:
{
"Command": "Success",
"From": "P-408106",
"To": "Originator",
"TrackNo": "Ex-3",
"Content": {
"Speed.Print-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 6,
"Min": 1,
"Max": 8,
"Inc": 1
},
"Speed.Print-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e152.4",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4", "e177.8", "e203.2"]
},
"Speed.Rev-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 2,
"Min": 1,
"Max": 6,
"Inc": 1
},
"Speed.Rev-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e50.8",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4"]
},
"Speed.Slew-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 6,
"Min": 1,
"Max": 8,
"Inc": 1
},
"Speed.Slew-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e152.4",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4", "e177.8", "e203.2"]
},
"Speed.SlewControl": {
"Type": "Enum",
"Perm": "RW",
"Value": "eAutomatic",
"Options": ["eAutomatic", "eManual"]
},
"ODV.Symbol.Codabar-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code128-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code39-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code93-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.DataMatrix-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Graphics-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Int25-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Orient": {
"Type": "Enum",
"Perm": "RW",
"Value": "eAll",
"Options": ["eAll", "ePicket", "eLadder"]
},
"ODV.Symbol.PDF417-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.QR-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.UPCEAN-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"Label.Sensor": {
"Type": "Enum",
"Perm": "RW",
"Value": "eGap",
"Options": ["eDisable", "eMark", "eGap"]
}
}