From d2a388c77a761b82d737ca63f3f5cfb18c435dca Mon Sep 17 00:00:00 2001 From: Frederico d' Almeida Santos <48219465+kikofmas@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:05:13 +0000 Subject: [PATCH] Docker container (#13) * Fixed .csv header with correct information. Updated version number. Added docker container for linux. --- Dockerfile | 22 ++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ scientisst/__init__.py | 2 +- sense_src/file_writer.py | 13 +++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..98bae62 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:jammy-20240911.1 + +# Install dependencies for pycairo, pyobject and pydbus +RUN apt update +RUN apt install -y python3.10 +RUN apt install -y python3-pip +RUN apt install -y wget +RUN apt install -y libcairo2-dev libxt-dev libgirepository1.0-dev +RUN apt install -y build-essential libdbus-glib-1-dev libgirepository1.0-dev +RUN apt install -y ninja-build patchelf bluez dbus bluetooth + +# Start bluetooth services +RUN service dbus start +RUN service bluetooth start + +# Copy requirements file and install python requirements +COPY requirements.txt ./ +RUN pip3 install meson +RUN pip3 install --no-cache-dir -r requirements.txt + +# Copy all files to container +COPY . . diff --git a/README.md b/README.md index 7d3c774..8115e22 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,34 @@ Install them using `pip`: pip install -r requirements.txt ``` +## Using Docker in Linux + +When running the API on Linux, if issues arise, it is recommended to try using it inside a docker container. + +First, install [docker](https://docs.docker.com/engine/install/). + +Then, clone the repository and navigate to the directory: +```sh +# Getting this repository +git clone https://github.com/scientisst/scientisst-sense-api-python.git +cd scientisst-sense-api-python +``` + +Then, build the docker container with: +```sh +sudo docker build -t sense_docker . +``` + +It is required to build the container only once. Finally, run the container with: +```sh +sudo docker run -v /var/run/dbus/:/var/run/dbus/:z --privileged -it sense_docker +``` + +This will open a terminal inside the container with access to bluetooth and Wi-Fi. To exit the container run: +```sh +exit +``` + ## Running ### Automatic diff --git a/scientisst/__init__.py b/scientisst/__init__.py index 1b9b42a..41cd9ba 100644 --- a/scientisst/__init__.py +++ b/scientisst/__init__.py @@ -1,3 +1,3 @@ from scientisst.scientisst import * -__version__ = "1.1.0" +__version__ = "1.2.0" diff --git a/sense_src/file_writer.py b/sense_src/file_writer.py index 631dc4a..23214b8 100644 --- a/sense_src/file_writer.py +++ b/sense_src/file_writer.py @@ -56,6 +56,19 @@ def __get_metadata(self, address, fs, channels, api_version, firmware_version, a "Timestamp": timestamp.timestamp(), "ISO 8601": timestamp.isoformat(), } + if API_MODE_DICT[api_com_version] == API_MODE_SCIENTISST: + metadata = { + "API version": api_version, + "Channels": channels, + "Channels labels": get_channel_labels(channels, self.mv), + "Device": address, + "Firmware version": firmware_version, + "Header": get_header(channels, self.mv, api_com_version), + "Resolution (bits)": [12, 1, 1, 1, 1] + self.__get_channel_resolutions(), + "Sampling rate (Hz)": fs, + "Timestamp": timestamp.timestamp(), + "ISO 8601": timestamp.isoformat(), + } else: metadata = { "API version": api_version,