Skip to content

Commit c7ab505

Browse files
committed
Python HAL doc: Document functions that throw a RuntimeError
1 parent 090eefa commit c7ab505

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

docs/src/config/python-hal-interface.adoc

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ System information:
7373

7474
hal.is_initialized()::
7575
Returns a boolean to indicate whether hal is initialized. The hal is initialized when there is
76-
at least one component. If this is not the case, many of the following functions will
77-
fail with the error: `Cannot call before creating component`
76+
at least one component. If this is not the case, many of the following functions will throw
77+
a `RuntimeError` exception: `Cannot call before creating component`
7878

7979
.Example:
8080
[source,python]
@@ -94,14 +94,17 @@ type = hal.get_realtime_type()
9494
hal.get_realtime_type()::
9595
Returns the type of the running realtime system.
9696
Might return `hal.REALTIME_TYPE_UNINITIALIZED` if `rtapi_app` is not running.
97-
See xref:_hal_constants[realtime type constants].
97+
See xref:_hal_constants[realtime type constants]. +
98+
Throws a `RuntimeError` exception if HAL is not initialized.
9899

99100
hal.component_exists(_name_:string)::
100-
Returns a boolean to indicate whether or not the specified component exist at this time.
101+
Returns a boolean to indicate whether or not the specified component exist at this time. +
102+
Throws a `RuntimeError` exception if HAL is not initialized.
101103

102104
hal.component_is_ready(_name_:string)::
103105
Returns a boolean to indicate whether or not the specified component is in the ready state.
104-
Also returns False if the component does not exist.
106+
Also returns False if the component does not exist. +
107+
Throws a `RuntimeError` exception if HAL is not initialized.
105108

106109
.Example:
107110
[source,python]
@@ -123,7 +126,8 @@ See 'hal.set_msg_level()' and xref:_hal_constants[message constants] for list of
123126
hal.new_sig(_name_:string, _type_:enum)::
124127
Create a new signal (net) called _name_.
125128
The signal can carry information of _type_ content.
126-
Returns `True` on success.
129+
Returns `True` on success. +
130+
Throws a `RuntimeError` exception if HAL is not initialized.
127131

128132
.Example:
129133
[source,python]
@@ -135,7 +139,8 @@ if not hal.new_sig("signalname", hal.HAL_BIT):
135139
hal.connect(_pinname_:string, _signame_:string)::
136140
Connect the pin _pinname_ to signal _signame_.
137141
Both signal and pin must exist and both pin and signal must be of the same type.
138-
Returns `True` on success.
142+
Returns `True` on success. +
143+
Throws a `RuntimeError` exception if HAL is not initialized.
139144

140145
.Example:
141146
[source,python]
@@ -147,7 +152,8 @@ if not hal.connect("mycomp.pinname", "signalname"):
147152
hal.disconnect(_pinname_:string, _signame_:string)::
148153
Disconnect the pin _pinname_ from signal _signame_.
149154
Both signal and pin must exist.
150-
Returns `True` on success.
155+
Returns `True` on success. +
156+
Throws a `RuntimeError` exception if HAL is not initialized.
151157

152158
.Example:
153159
[source,python]
@@ -158,7 +164,8 @@ if not hal.disconnect("mycomp.pinname"):
158164

159165
hal.pin_has_writer(_pinname_:string)::
160166
Returns `True` if pin with name _pinname_ is attached to a signal and there is at least one writer.
161-
Otherwise, `False` is returned.
167+
Otherwise, `False` is returned. +
168+
Throws a `RuntimeError` exception if HAL is not initialized.
162169

163170
.Example:
164171
[source,python]
@@ -172,8 +179,9 @@ else:
172179
hal.set_p(_name_:string, _value_:mixed)::
173180
Sets the pin or param called _name_ to _value_.
174181
The _name_ is the full name of the pin or param.
175-
The search order is pin names first, then parameter names.
182+
The search order is pin names first, then parameter names. +
176183
Throws a `RuntimeError` exception if the _name_ is not found. +
184+
Throws a `RuntimeError` exception if HAL is not initialized. +
177185
The type of _value_ depends on the type of the pin or param.
178186
Integer scalar types may use integers or a textual representation of an integer to set the value.
179187
Floating point type may use both integer, floating point and textual representation thereof to set the value.
@@ -195,14 +203,16 @@ The same rules for _value_ apply to 'set_s()' as to 'set_p()'. +
195203
+
196204
The 'set_s()' method has one special case when the signal is of type `hal.HAL_PORT` and it is fully connected.
197205
In that case, the call uses the _value_ to set the port's queue size and it must be a positive integer.
198-
See below xref:_hal_port_pipes[on configuring a port].
206+
See below xref:_hal_port_pipes[on configuring a port]. +
207+
Throws a `RuntimeError` exception if HAL is not initialized.
199208

200209
hal.get_value(_name_:string)::
201210
Returns the value of the pin, param or signal with _name_, searched in that order.
202211
Boolean types return `True` or `False`.
203212
Integer scalar types return an integer.
204213
Floating point types return a float.
205-
A `RuntimeError` exception is thrown if no pin, param or signal is found by that name.
214+
A `RuntimeError` exception is thrown if no pin, param or signal is found by that name. +
215+
Throws a `RuntimeError` exception if HAL is not initialized.
206216

207217
.Example:
208218
[source,python]
@@ -211,13 +221,16 @@ value = hal.get_value("iocontrol.0.emc-enable-in")
211221
----
212222

213223
hal.get_info_pins()::
214-
Returns a list of dictionary tuples as in `{"NAME":"pinname", "VALUE":<bool|int|float>, "TYPE":<int>, "DIRECTION":<int>}`.
224+
Returns a list of dictionary tuples as in `{"NAME":"pinname", "VALUE":<bool|int|float>, "TYPE":<int>, "DIRECTION":<int>}`. +
225+
Throws a `RuntimeError` exception if HAL is not initialized.
215226

216227
hal.get_info_params()::
217-
Returns a list of dictionary tuples as in `{"NAME":"paramname", "VALUE":<bool|int|float>, "TYPE":<int>, "DIRECTION":<int>}`.
228+
Returns a list of dictionary tuples as in `{"NAME":"paramname", "VALUE":<bool|int|float>, "TYPE":<int>, "DIRECTION":<int>}`. +
229+
Throws a `RuntimeError` exception if HAL is not initialized.
218230

219231
hal.get_info_signals()::
220-
Returns a list of dictionary tuples as in `{"NAME":"signame", "VALUE":<bool|int|float>, "TYPE":<int>, "DRIVER":"name"|None}`.
232+
Returns a list of dictionary tuples as in `{"NAME":"signame", "VALUE":<bool|int|float>, "TYPE":<int>, "DRIVER":"name"|None}`. +
233+
Throws a `RuntimeError` exception if HAL is not initialized.
221234

222235
.Example:
223236
[source,python]

0 commit comments

Comments
 (0)