Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pi 5 support #67

Merged
merged 19 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*
daqhats.egg-info/*
**/build/*
**/daqhats.egg-info/*
dist/*
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<tr><td>Info</td><td>Contains C and Python Libraries for interacting with
Measurement Computing DAQ HAT boards.</td></tr>
<tr><td>Author</td><td>Measurement Computing</td></tr>
<tr><td>Library Version<td>1.4.0.8</td></tr>
<tr><td>Library Version<td>1.5.0.0</td></tr>
</table>

## About
Expand Down Expand Up @@ -38,7 +38,7 @@ specifications for that device.
## Prerequisites
- Raspberry Pi OS or Raspbian image (may work with other Raspberry Pi operating systems)
- Raspberry Pi with 40-pin GPIO header
- C, C++, Python 2.7 or Python 3.4
- C, C++, Python 2.7 or Python 3.4+

## Raspberry Pi Configuration
Follow the instructions at https://www.raspberrypi.org/help/ for setting up a Raspberry Pi.
Expand Down Expand Up @@ -66,29 +66,47 @@ Follow the instructions at https://www.raspberrypi.org/help/ for setting up a Ra
5. Install git (if not installed):

```sh
sudo apt install git
sudo apt install git -y
```
6. Download the daqhats library to the root of your home folder:

```sh
cd ~
git clone https://github.com/mccdaq/daqhats.git
```
7. Build and install the shared library, tools, and optional Python support. The
installer will install Python 3 support by default and ask if you want to install
Python 2 support. It will also detect the HAT board EEPROMs and save the contents,
if needed.
7. Build and install the shared library and tools. It will also detect the HAT board EEPROMs
and save the contents, if needed.

```sh
cd ~/daqhats
sudo ./install.sh
```
8. To use the daqhats library with Python install the python library. It may be
installed system-wide with:
```sh
sudo pip install daqhats
```
Recent versions of Python discourage system-wide installation, so you may have
to append *--break-system-packages*. To install in a virtual environment (venv),
create the venv and install the package (replace `<path_to_venv>` with the desired
location of the venv):
```sh
python -m venv <path_to_venv>
<path_to_venv>/bin/pip install daqhats
```

**Note:** If you encounter any errors during steps 5 - 7 then uininstall the daqhats
library (if installed), go back to step 4, update your installed packages and reboot,
then repeat steps 5 - 7.

If ioctl errors are seen when running on a Raspberry Pi 5, update the kernel with:
```sh
sudo rpi-update
```

You can now run the example programs under ~/daqhats/examples and create your own
programs. Refer to the [Examples](#examples) section below for more information.
The Python library must be installed to run the Python examples.

If you are using the Raspberry Pi OS desktop interface, the DAQ HAT Manager utility will be
available under the Accessories start menu. This utility will allow you to list the
Expand All @@ -115,13 +133,25 @@ sudo daqhats_read_eeproms
The command **daqhats_version** may be used to display the installed version number.

#### Uninstall the daqhats library
If you want to uninstall the the daqhats library, use the following commands:
To uninstall the the daqhats library:

```sh
cd ~/daqhats
sudo ./uninstall.sh
```

To uninstall a system-wide Python library:

```sh
sudo pip uninstall daqhats
```

To uninstall the Python library from a venv (replace `<path_to_venv>` with the path of the venv):

```sh
<path_to_venv>/bin/pip uninstall daqhats
```

## Firmware Updates
The library firmware version for applicable devices can be found in
[tools/README.md](./tools/README.md).
Expand Down
5 changes: 3 additions & 2 deletions daqhats/mcc118.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ def a_in_scan_start(self, channel_mask, samples_per_channel,
data. Certain methods like :py:func:`a_in_read` will return an error
because the device is busy.

The scan options that may be used are:
The scan options that may be used are below. Multiple options can be
combined with OR (|).

* :py:const:`OptionFlags.DEFAULT`: Return scaled and calibrated data,
internal scan clock, no trigger, and finite operation. Any other flags
Expand All @@ -473,7 +474,7 @@ def a_in_scan_start(self, channel_mask, samples_per_channel,
circular buffer. The data must be read before being overwritten to
avoid a buffer overrun error. **samples_per_channel** is only used for
buffer sizing.

The scan buffer size will be allocated as follows:

**Finite mode:** Total number of samples in the scan.
Expand Down
3 changes: 2 additions & 1 deletion daqhats/mcc128.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ def a_in_scan_start(self, channel_mask, samples_per_channel,
data. Certain methods like :py:func:`a_in_read` will return an error
because the device is busy.

The scan options that may be used are:
The scan options that may be used are below. Multiple options can be
combined with OR (|).

* :py:const:`OptionFlags.DEFAULT`: Return scaled and calibrated data,
internal scan clock, no trigger, and finite operation. Any other flags
Expand Down
3 changes: 2 additions & 1 deletion daqhats/mcc172.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@ def a_in_scan_start(self, channel_mask, samples_per_channel, options):
data. Certain methods like :py:func:`a_in_clock_config_write` will
return an error because the device is busy.

The scan options that may be used are:
The scan options that may be used are below. Multiple options can be
combined with OR (|).

* :py:const:`OptionFlags.DEFAULT`: Return scaled and calibrated data,
do not use a trigger, and finite operation. Any other flags will
Expand Down
19 changes: 17 additions & 2 deletions docs/_sources/install.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,33 @@ Installation
cd ~
git clone https://github.com/mccdaq/daqhats.git

7. Build and install the shared library and optional Python support. The installer will ask if you want to install Python 2 and Python 3 support. It will also detect the HAT board EEPROMs and save the contents if needed::
7. Build and install the shared library and tools. The installer will detect the HAT board EEPROMs and save the contents if needed::

cd ~/daqhats
sudo ./install.sh

8. To use the daqhats library with Python install the python library. It may be installed system-wide with::

sudo pip install daqhats

Recent versions of Python discourage system-wide installation, so you may have to append ``--break-system-packages``.
To install in a virtual environment (venv), create the venv and install the package (replace ``<path_to_venv>`` with the
desired location of the venv)::

python -m venv <path_to_venv>
<path_to_venv>/bin/pip install daqhats

**Note:** If you encounter any errors during steps 5 - 7 then uininstall the daqhats
library (if installed), go back to step 4, update your installed packages and reboot,
then repeat steps 5 - 7.

if ioctl errors are seen when running on a Raspberry Pi 5, update the kernel with::

sudo rpi-update

You can now run the example programs under ~/daqhats/examples and create your own programs.

If you are using the Raspbian desktop interface, the DAQ HAT Manager utility will be
If you are using the Raspberry Pi OS desktop interface, the DAQ HAT Manager utility will be
available under the Accessories start menu. This utility will allow you to list the
detected DAQ HATs, update the EEPROM files if you change your board stack, and launch
control applications for each DAQ HAT to perform simple operations. The code for these
Expand Down
123 changes: 123 additions & 0 deletions docs/_static/_sphinx_javascript_frameworks_compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* Compatability shim for jQuery and underscores.js.
*
* Copyright Sphinx contributors
* Released under the two clause BSD licence
*/

/**
* small helper function to urldecode strings
*
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
*/
jQuery.urldecode = function(x) {
if (!x) {
return x
}
return decodeURIComponent(x.replace(/\+/g, ' '));
};

/**
* small helper function to urlencode strings
*/
jQuery.urlencode = encodeURIComponent;

/**
* This function returns the parsed url parameters of the
* current request. Multiple values per key are supported,
* it will always return arrays of strings for the value parts.
*/
jQuery.getQueryParameters = function(s) {
if (typeof s === 'undefined')
s = document.location.search;
var parts = s.substr(s.indexOf('?') + 1).split('&');
var result = {};
for (var i = 0; i < parts.length; i++) {
var tmp = parts[i].split('=', 2);
var key = jQuery.urldecode(tmp[0]);
var value = jQuery.urldecode(tmp[1]);
if (key in result)
result[key].push(value);
else
result[key] = [value];
}
return result;
};

/**
* highlight a given string on a jquery object by wrapping it in
* span elements with the given class name.
*/
jQuery.fn.highlightText = function(text, className) {
function highlight(node, addItems) {
if (node.nodeType === 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 &&
!jQuery(node.parentNode).hasClass(className) &&
!jQuery(node.parentNode).hasClass("nohighlight")) {
var span;
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
if (isInSVG) {
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
} else {
span = document.createElement("span");
span.className = className;
}
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
if (isInSVG) {
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
var bbox = node.parentElement.getBBox();
rect.x.baseVal.value = bbox.x;
rect.y.baseVal.value = bbox.y;
rect.width.baseVal.value = bbox.width;
rect.height.baseVal.value = bbox.height;
rect.setAttribute('class', className);
addItems.push({
"parent": node.parentNode,
"target": rect});
}
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this, addItems);
});
}
}
var addItems = [];
var result = this.each(function() {
highlight(this, addItems);
});
for (var i = 0; i < addItems.length; ++i) {
jQuery(addItems[i].parent).before(addItems[i].target);
}
return result;
};

/*
* backward compatibility for jQuery.browser
* This will be supported until firefox bug is fixed.
*/
if (!jQuery.browser) {
jQuery.uaMatch = function(ua) {
ua = ua.toLowerCase();

var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];

return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
jQuery.browser = {};
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
}
Binary file removed docs/_static/ajax-loader.gif
Binary file not shown.
Loading