RS232 API Documentation

Overview

The FLC system provides an RS232/UART interface for remote control and monitoring. This API allows external systems to execute routines, control hardware, and monitor the status of the laser system.

Available Sections

routines NLOS

Connection Parameters

To connect to the RS232 API, use the following parameters:

Command Format

All commands follow a simple text-based format:

command [parameter1] [parameter2] ...

For example:

write_digital ONHV 0 true

Response Format

Responses are returned as strings and can be one of the following formats:

Command Categories

The RS232 API commands are divided into two main categories:

  1. Direct Hardware Control: Commands that directly control hardware functions like digital/analog I/O
  2. Routine Execution: Commands that execute pre-defined routines

Parameter Handling

When executing routines that require parameters, values should be provided in the correct order and format:

For example, if a routine requires a wavelength parameter:

run_set_wavelength 1064.5

Error Handling

If a command fails during execution, an error message will be returned with the following format:

ERROR: <error message>

Common errors include:

RS232 API Documentation - routines

Back to Index

Overview

This document describes the RS232 API commands available for the routines subsystem.

Direct Hardware Control Commands

Interface Control

write_digital

Callback function for the digital output buttons (ToggleButtons).

Format: write_digital <name> <portnum> <state>

Parameters: - name: string - portnum: integer - state: boolean value ("true"/"false" or "1"/"0")

Example: write_digital ONHV 0 true

Returns: Success/error status and the written value

Description: This command directly controls the digital outputs of the control board. It's used to toggle hardware components on and off, such as power supplies, high voltage sources, and pulse generators.

write_analog

Callback function for the analog output buttons (DACGroup).

Format: write_analog <name> <portnum> <value>

Parameters: - name: string - portnum: integer - value: float

Example: write_analog DAC1 2 3.5

Returns: Success/error status and the written value

Description: This command controls analog outputs, allowing precise control of voltage levels for components such as DACs (Digital-to-Analog Converters). It's used for controlling variable parameters like power levels and timing signals.

Adc Control

adc_single_offload

Perform single offload Example command: 'GET adc_single_offload'

Format: adc_single_offload

Example: adc_single_offload

Returns: ADC data or success message

Description: This command reads the current ADC data from BRAM (Block RAM) registers and returns the values. It's useful for checking analog signal values at a specific moment in time.

adc_continuous_offload

Perform single offload Example command: 'GET adc_single_offload'

Format: adc_continuous_offload <state>

Parameters: - state: boolean value ("true"/"false" or "1"/"0")

Example: adc_continuous_offload true

Returns: ADC data or success message

Description: This command controls the continuous reading of ADC data. When enabled, the system will continuously read and transmit ADC values until disabled. This is useful for monitoring analog signals over time.

Available Routines for routines

The following routines are registered in the routines subsystem and can be executed via RS232:

run_measure_and_check_signals

Check Signals

View Sequence Diagram

Format: run_measure_and_check_signals <frequency>

Example: run_measure_and_check_signals "example_string"

Description:

Steps:


run_measure_and_check_signals

Check Signals

View Sequence Diagram

Format: run_measure_and_check_signals

Example: run_measure_and_check_signals

Description:

Steps:


Back to Index

RS232 API Documentation - NLOS

Back to Index

Overview

This document describes the RS232 API commands available for the NLOS subsystem.

Direct Hardware Control Commands

Interface Control

write_digital

Callback function for the digital output buttons (ToggleButtons).

Format: write_digital <name> <portnum> <state>

Parameters: - name: string - portnum: integer - state: boolean value ("true"/"false" or "1"/"0")

Example: write_digital ONHV 0 true

Returns: Success/error status and the written value

Description: This command directly controls the digital outputs of the control board. It's used to toggle hardware components on and off, such as power supplies, high voltage sources, and pulse generators.

write_analog

Callback function for the analog output buttons (DACGroup).

Format: write_analog <name> <portnum> <value>

Parameters: - name: string - portnum: integer - value: float

Example: write_analog DAC1 2 3.5

Returns: Success/error status and the written value

Description: This command controls analog outputs, allowing precise control of voltage levels for components such as DACs (Digital-to-Analog Converters). It's used for controlling variable parameters like power levels and timing signals.

Adc Control

adc_single_offload

Perform single offload Example command: 'GET adc_single_offload'

Format: adc_single_offload

Example: adc_single_offload

Returns: ADC data or success message

Description: This command reads the current ADC data from BRAM (Block RAM) registers and returns the values. It's useful for checking analog signal values at a specific moment in time.

adc_continuous_offload

Perform single offload Example command: 'GET adc_single_offload'

Format: adc_continuous_offload <state>

Parameters: - state: boolean value ("true"/"false" or "1"/"0")

Example: adc_continuous_offload true

Returns: ADC data or success message

Description: This command controls the continuous reading of ADC data. When enabled, the system will continuously read and transmit ADC values until disabled. This is useful for monitoring analog signals over time.

Available Routines for NLOS

The following routines are registered in the NLOS subsystem and can be executed via RS232:

run_divide_frequency

Divide Frequency

View Sequence Diagram

Format: run_divide_frequency <divider>

Example: run_divide_frequency 123.45

Description:

Steps:


run_check_laser_status

Check Laser status

View Sequence Diagram

Format: run_check_laser_status

Example: run_check_laser_status

Description:

Steps:


run_arm_laser

Arm Laser

View Sequence Diagram

Format: run_arm_laser <frequency>

Example: run_arm_laser "example_string"

Description:

Steps:


run_disarm_laser

Disarm laser

View Sequence Diagram

Format: run_disarm_laser

Example: run_disarm_laser

Description:

Steps:


run_shutdown_laser

Shutdown Laser

View Sequence Diagram

Format: run_shutdown_laser

Example: run_shutdown_laser

Description:

Steps:


run_emission_on

Emission ON

View Sequence Diagram

Format: run_emission_on

Example: run_emission_on

Description:

Steps:


run_emission_off

Emission OFF

View Sequence Diagram

Format: run_emission_off

Example: run_emission_off

Description:

Steps:


Back to Index

Example Usage Sequences

Complete Startup Sequence

run_emission_on

Safe Shutdown Sequence

run_shutdown_laser
run_emission_off

Status Check and Monitoring

run_measure_and_check_signals
adc_single_offload

Manual Control Example

write_digital PS_ON 0 true
write_digital ON11V 0 true
write_digital ONHV 0 true
write_analog DAC1 2 3.5

Data Collection Sequence

adc_continuous_offload true
# Monitor data for some time
adc_continuous_offload false

Back to Index

Troubleshooting

Connection Issues

Command Execution Problems

Hardware Communication

System State Issues

Debugging Tips

Back to Index

Implementation Details

The RS232 API is implemented using a UART router that:

  1. Listens for incoming commands on the configured UART port
  2. Parses the command and extracts parameters
  3. Executes the corresponding function or routine
  4. Returns the result to the sender

All routines marked with register-api: true in their YAML configuration are automatically registered for RS232 access with the prefix run_.

The system uses regex pattern matching to identify commands and extract parameters. Function handlers are registered for each command pattern using the @uart_route decorator or through automatic registration of routines.

Back to Index