Skip to content

Commit

Permalink
Fix rendering of code (#571)
Browse files Browse the repository at this point in the history
* Fix rendering of code

* Fix list rendering

* Small grammatical things

* Small formatting and grammar fixes

* Missing words
  • Loading branch information
jpsecher committed Jan 9, 2021
1 parent ca14339 commit bb8fd9d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
15 changes: 8 additions & 7 deletions docs/source/introduction/event_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Event handling

VISA supports generating events on the instrument side usually when a register
change and handling then on the controller using two different mechanisms:

- storing the events in a queue
- calling a dedicated handler function registered for that purpose when the
event occurs
event occurs

PyVISA supports using both mechanism and tries to provide a convenient interface
to both. Below we give a couple of example of how to use each mechanism (using
Expand Down Expand Up @@ -66,22 +67,22 @@ time and start the operation that will lead to the event. For the sake of that
example we are going to consider a Service Request event. Usually service request
can be enabled for a range of register state, the details depending on the
instrument. One useful case is to generate a service request when an operation
is complete which is we are pretending to do here.
is complete which is what we are pretending to do here.

Finally we wait for the event to occur and we specify a timeout of 1000ms to
avoid waiting for ever. Once we received the event we disable event handling.
avoid waiting forever. Once we receive the event we disable event handling.


Registering handlers for event
------------------------------

Rather than waiting for an event, it can sometimes be convenient to take immediate
action when an event occurs, in which having the VISA library call directly a function
can be useful. Let see how.
action when an event occurs, in which case having the VISA library call a function
directly can be useful. Let's see how.

.. note::

One can enable event handling using both mechanisms (constants.EventMechanism.all)
One can enable event handling using both mechanisms (``constants.EventMechanism.all``)

.. code-block:: python
Expand Down Expand Up @@ -151,7 +152,7 @@ Next we install the handler and enable the event processing:
user_handle = instr.install_handler(event_type, wrapped, 42)
instr.enable_event(event_type, event_mech, None)
When installing a handler one can optionally, specify a user handle that will be
When installing a handler one can optionally specify a user handle that will be
passed to the handler. This handle can be used to identify which handler is called
when registering the same handler multiple times on the same resource. That value
may have to be converted by the backend. As a consequence the value passed to
Expand Down
4 changes: 2 additions & 2 deletions docs/source/introduction/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ SCPI and/or Keithley 2000 manual.
>>> keithley.write("trace:feed sense1; trace:feed:control next")
Okay, now the instrument is prepared to do the measurement. The next
three lines make the instrument waiting for a trigger pulse, trigger
three lines make the instrument wait for a trigger pulse, trigger
it, and wait until it sends a "service request"::

>>> keithley.write("initiate")
>>> keithley.assert_trigger()
>>> keithley.wait_for_srq()

With sending the service request, the instrument tells us that the
By sending the service request, the instrument tells us that the
measurement has been finished and that the results are ready for
transmission. We could read them with `keithley.query("trace:data?")`
however, then we'd get:
Expand Down
16 changes: 8 additions & 8 deletions docs/source/introduction/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Resources
A resource represents an instrument, e.g. a measurement device. There are
multiple classes derived from resources representing the different available
types of resources (eg. GPIB, Serial). Each contains the particular set of
attributes an methods that are available by the underlying device.
attributes and methods that are available by the underlying device.

You do not create this objects directly but they are returned by the
You do not create these objects directly but they are returned by the
|open_resource| method of a |ResourceManager|. In general terms, there
are two main groups derived from |Resource|, |MessageBasedResource| and
|RegisterBasedResource|.
Expand Down Expand Up @@ -53,7 +53,7 @@ If the resource is closed, an exception will be raised:
timeout
~~~~~~~

Very most VISA I/O operations may be performed with a timeout. If a timeout is
Most VISA I/O operations may be performed with a timeout. If a timeout is
set, every operation that takes longer than the timeout is aborted and an
exception is raised. Timeouts are given per instrument in **milliseconds**.

Expand All @@ -71,12 +71,12 @@ is set to 25 seconds. To set an **infinite** timeout, set it to ``None`` or
del my_device.timeout
To set it to **immediate**, set it to `0` or a negative value. (Actually, any
value smaller than 1 is considered immediate)

Now every operation of the resource takes as long as it takes, even
indefinitely if necessary.

To set it to **immediate**, set it to `0` or a negative value. (Actually, any
value smaller than 1 is considered immediate)


Attributes of MessageBase resources
-----------------------------------
Expand Down Expand Up @@ -184,7 +184,7 @@ VISA attributes

In addition to the above mentioned attributes, you can access most of the VISA
attributes as defined in the visa standard on your resources through properties.
Those properties will take for you of converting Python values to values VISA
Those properties will take care of converting Python values to VISA
values and hence simplify their manipulations. Some of those attributes also
have lighter aliases that makes them easier to access as illustrated below:

Expand All @@ -204,7 +204,7 @@ have lighter aliases that makes them easier to access as illustrated below:
``attr`` command.

You can also manipulate the VISA attributes using |get_visa_attribute| and
|set_visa_attribute|. However you will have use the proper values (as defined in
|set_visa_attribute|. However you will have to use the proper values (as defined in
:mod:`pyvisa.constants`) both to access the attribute and to specify the value.

.. code:: python
Expand Down
12 changes: 6 additions & 6 deletions docs/source/introduction/rvalues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ termination character at the end of the message.
If you can read without any problem from your instrument, but cannot retrieve
the full message when using this method (VI_ERROR_CONN_LOST,
VI_ERROR_INV_SETUP, or Python simply crashes), try passing different values for
``chunk_size``(the default is 20*1024). The underlying mechanism for this issue
``chunk_size`` (the default is 20*1024). The underlying mechanism for this issue
is not clear but changing ``chunk_size`` has been used to work around it. Note
that using larger chunk sizes for large transfer may result in a speed up of
the transfer.

In some cases, the instrument may use a protocol that does not indicate how
many bytes will be transferred. The Keithley 2000 for example always return the
full buffer whose size is reported by the 'trace:points?' command. Since a
binary block may contain the termination character, PyVISA need to know how
many bytes will be transferred. The Keithley 2000 for example always returns the
full buffer whose size is reported by the ``trace:points?`` command. Since a
binary block may contain the termination character, PyVISA needs to know how
many bytes to expect. For those case, you can pass the expected number of
points using the ``data_points`` keyword argument. The number of bytes will be
inferred from the datatype of the block.
Expand Down Expand Up @@ -144,7 +144,7 @@ The separator can also be specified just like in ``query_ascii_values``.

>>> inst.write_ascii_values('WLISt:WAVeform:DATA somename,', values, converter='x', separator='$')

You can provide a function to takes a iterable and returns an string.
You can provide a function that takes a iterable and returns a string.
Default value for the separator is ``','`` (comma)


Expand All @@ -171,7 +171,7 @@ When things are not what they should be
PyVISA provides an easy way to transfer data from and to the device. The
methods described above work fine for 99% of the cases but there is always a
particular device that do not follow any of the standard protocols and is so
different that cannot be adapted with the arguments provided above.
different that it cannot be adapted with the arguments provided above.

In those cases, you need to get the data::

Expand Down

0 comments on commit bb8fd9d

Please sign in to comment.