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
-
+
The component itself is created by a call to the constructorhal.component. The arguments are the HAL component name and (optionally) the prefix used for pin and parameter names. If the prefix is not specified, the component name is used.
.Example
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.
hal.component_exists("testpanel")
- component_is_ready
-
Componente especificado listo en este momento.
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.
hal.connect("pinname","signal_name")
- disconnect
-
Desconecta un pin de una señal.
hal.disconnect("pinname")
- get_value
-
Lee un pin, parámetro o señal directamente.
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.
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
-
Get the HAL object name.
Return a string.
h.in.get_name()
- get_type
-
Get the HAL object’s type.
Returns an integer.
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.
hal.set_p("pinname","10")
- set_s
-
Establecer un valor de cualquier señal sin conexión en el sistema HAL.
hal.set_s("signalname","10")