This documentation describes the hal python module, which provides a Python API for creating and accessing HAL pins and signals.

1. Basic usage

#!/usr/bin/env python3
import hal, time
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()

2. Functions

component

+
El componente en sí es creado por una llamada al constructor hal.component. Los argumentos son el nombre del componente HAL y (opcionalmente) el prefijo utilizado para los nombres de los pines y los parámetros. Si el prefijo no se especifica, se usa el nombre del componente.
.Ejemplo

h = hal.component("passthrough")
newpin

+
Crea pin nuevo.
Argumentos: sufijo del nombre del pin, tipo de pin y dirección del pin. Para parámetros, los argumentos son: sufijo del nombre del parámetro, tipo de parámetro, y dirección del parámetro.
.Ejemplo:

h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
ready

Tells the HAL system the component is initialized. Locks out adding pins.

unready

Allows a component to add pins after ready() has been called. One should call ready() on the component after.

component_exists

Existencia del componente especificado en este momento.

Example
hal.component_exists("testpanel")
component_is_ready

Componente especificado listo en este momento.

Example
hal.component_is_ready("testpanel")
get_msg_level

Get the current Realtime msg level.

set_msg_level

Set the current Realtime msg level. used for debugging information.

connect

Conecta un pin a una señal.

Example
hal.connect("pinname","signal_name")
disconnect

Desconecta un pin de una señal.

Example
hal.disconnect("pinname")
get_value

Lee un pin, parámetro o señal directamente.

Example
value = hal.get_value("iocontrol.0.emc-enable-in")
get_info_pins()

Returns a list of dicts of all system pins.

listOfDicts = hal.get_info_pins()
pinName1 = listOfDicts[0].get('NAME')
pinValue1 = listOfDicts[0].get('VALUE')
pinType1 = listOfDicts[0].get('TYPE')
pinDirection1 = listOfDicts[0].get('DIRECTION')
get_info_signals()

Returns a list of dicts of all system signals.

listOfDicts = hal.get_info_signals()
signalName1 = listOfDicts[0].get('NAME')
signalValue1 = listOfDicts[0].get('VALUE')
driverPin1 = listOfDicts[0].get('DRIVER')
get_info_params()

Returns a list of dicts of all system parameters.

listOfDicts = hal.get_info_params()
paramName1 = listOfDicts[0].get('NAME')
paramValue1 = listOfDicts[0].get('VALUE')
paramDirection1 = listOfDicts[0].get('DIRECTION')
new_sig

Crea una nueva señal del tipo especificado.

Example
hal.new_sig("signalname",hal.HAL_BIT)
pin_has_writer

Does the specified pin have a driving pin connected.
Returns True or False.

h.in.pin_has_writer()
get_name

Obtener nombre de objeto HAL.
Devuelve una cadena.

h.in.get_name()
get_type

Obtener tipo de objeto HAL.
Devuelve un entero.

h.in.get_type()
get_dir

Get the HAL object direction type.
Returns an integer.

h.in.get_dir()
get

Get the HAL object value.

h.in.get()
set

Set the HAL object value.

h.out.set(10)
is_pin

Is the object a pin or parameter?
Returns True or False.

h.in.is_pin()
sampler_base

TODO

stream_base

TODO

stream

TODO

set_p

Establecer un valor en cualquier pin en el sistema HAL.

Example
hal.set_p("pinname","10")
set_s

Establecer un valor de cualquier señal sin conexión en el sistema HAL.

Example
hal.set_s("signalname","10")