C API for BALTECH SDK

§ brp_AR_RunScript()

brp_errcode brp_AR_RunScript ( brp_protocol  protocol,
brp_buf  Script,
size_t  Script_len 
)

This command runs a BaltechScript. This is a small sequence of instructions for the reader to execute. Typically, it's used to control reader feedback, i.e. LEDs, beeper, relay, and other I/O ports when you have highly specific requirements and/or want to store the script on the reader.

Instead of AR.RunScript , we recommend theUI command set as it's easier to implement and sufficient for the majority of use cases.

Script structure

A script consists of the following parts:

  • Frame value (e.g. 0x01 for Enable)
  • Port (e.g. 0x00 for the green LED)
  • Parameters if applicable (e.g. number of repetitions and delay after each change of state)

Examples

Here are a few examples of how to create a script. We'll use the following script commands as they're the most important ones:

  • Enable
  • Disable
  • Toggle
  • ToggleInverted

Single script to control 1 port

In this example, we'll switch on the green LED permanently. To do so, we need to run the Enable script as follows:

01 00

  • 01 is the frame value for Enable.
  • 00 is the parameter value for the green LED.

Sequence of scripts

You can run a sequence of scripts in parallel by concatenating them.

Simultaneous feedback sequence

In this example, we'll switch on the green LED permanently. At the same time, we have the beeper beep 3 times for 200 ms. To do so, we extend the Enable script from the above example with a Toggle script:

01 00 03 02 03 02

The Toggle script in this sequence is composed as follows:

  • 03 is the frame value for Toggle.
  • 02 is the parameter for the beeper.
  • 03 is the repeat count.
  • 02 is the delay :

The unit of this value is 1/10 sec, i.e. it's 200 ms in this example. This time period applies to the length of the beep and the delay afterwards, i.e. you have a duration of 2x200 ms per beep and a duration of 1200 ms for the entire sequence.

Consecutive feedback sequence

Concatenated scripts are always executed in parallel. However, you can still produce a consecutive feedback sequence using ToggleInverted and an appropriate delay. In this example, we'll use the toggle script from the above example to have the beeper beep 3 times for 200 ms. After the third beep, the red LED is enabled:

03 02 03 02 06 01 01 0C

The ToggleInverted script in this sequence is composed as follows:

  • 06 is the frame value for ToggleInverted.
  • 01 is the parameter for the red LED.
  • 01 is the repeat count.
  • 0C is the delay :

The unit of this value is 1/10 sec, i.e. it's 1200 ms in this example. This corresponds to the duration of the Toggle script that runs in parallel (see also previous example). Thus the LED (controlled by the ToggleInverted script) turns on after the beeper sequence (controlled by the Toggle script) is completed.

Parameters
[in]protocolused to execute the command
[in]ScriptScript to execute
[in]Script_len