Skip to content

handshake

EricGebhart edited this page Jun 9, 2021 · 1 revision

Handshake function

The handshake function is defined in the device module which is imported into the dev namespace. Therefore, more help is available.

See also:

  • help dev to get help for the dev namespace, which has imported the device extension module.
  • show device to see the Stateful data used by the device namespace
  • show config/device to see the configuration data used by the device namespace

Handshake is a generic function that is a bit more complicated.
It is at the core of the particle board functionality that SPR was originally created for.

Handshake manages an interaction with a device. Everything handshake does is defined in the configuration file. As with everything else, if anything fails, or doesn't match, an exception is raised.

Here are the steps that handshake() does.

  • Wait for the specified device path to appear.
  • Wait for the start_string, match it.
  • Respond with the response_string.
  • Look in the output for:
    • fail_regex,
    • done_regex,
    • do_qqc_regex.
  • If fail, raise an exception.
  • if done, exit quietly with true.
  • if do_qqc, then call the do_qqc_function and send the return value to the serial device.

qqc = quelque chose = something.

In the config the do_qqc_function is set to input-serial, as an example. Input-serial prompts for a serial number, validates it, and returns it. This function must be listed in the symbol table as that is where handshake() will look for it. Makes it easy to test. serial-input at the SPR:> prompt.

Clone this wiki locally