Skip to content

External Program Docs

crener edited this page Aug 29, 2017 · 4 revisions

The Scanner is able to communicate with an external program through a set of commands sent by the external program to the scanner.

Discovering all available scanners

To find a scanner or scanners of the network you must send a broadcast message on port 8470 (this is known as the discovery broadcast), every scanner which is not already connected externally or has error initialising the external API will respond to this via a message containing the name of the scanner (ASCII encoded) on port 8471 to the network address of the original broadcast request. For connecting to the scanner later you will need to save the network address which sent the message.

Note: a scanner will not send a response once a connection has been made by an external program, A scanner will not announce that it is no longer available or has become available so it is up to the external application to maintain lists of available scanners.

Connecting to a scanner

Once you know the address of a scanner you can connect to it. To do this must establish a TCP connection to the scanner on port 8472. Assuming there is no other device connected to the scanner at the time the request is received the scanner will automatically accept the connection. This TCP connection will exist as long as there is a connection with the external program. Once connected the external program may send any of the scanner requests outlined in the "Scanner requests section". Once the external program disconnects the scanner may take a few seconds to start accepting new connections or discovery broadcasts.

Scanner requests

Sending a request

A scanner request is an action that will be performed by the scanner, this can be anything from changing it's name, or getting the projects that the scanner currently has stored, to taking a new image set.

Each request must start with the request id which specifies the type of request that is required. If the request that you are performing needs parameters you must add a ? followed by each parameter in a key=value format with a & separator for multiple requests.

For example:

10?name=this is a scanner

This sends the change name request and supplies the request with a new name by specifying the name in the name parameter.

Note: A request from an external program is limited to 10240 characters, sending more characters will result in unexpected behaviour

Receiving a response

Once you have sent a request the scanner will return either an expected document depending on the request, a success message or fail message.

The standard response from a scanner is "Success" when there is no data to return from the request, and "Fail" followed by a separator "?" with an error message as to why the the scanner failed to resolve the request.

For Example A valid request:

10?name=new scanner name

returns

Success

or an invalid request:

10

returns

Fail?"name" parameter missing

Available Scanner Requests

These are the current scanner commands

General Commands

10 - Set Scanner Name

This changes the scanner name that is returned for a discovery broadcast

Expected Result

Success/Fail

Parameters

Key Value
name the new name the scanner will be known as

11 - set project name

todo

12 - get recent log file

todo

13 - get scanner projects

todo

14 - get camera configuration

todo

15 - get remaining storage capacity

todo

18 - get API version

todo

Camera Commands

20 - capture image set

todo

Project Commands

todo

RemoveProject = 30, getAllImageSets = 31, getImageSet = 32, getProjectStats = 33