adi-study-watch


Nameadi-study-watch JSON
Version 5.20.0 PyPI version JSON
download
home_pagehttps://github.com/analogdevicesinc/study-watch-sdk
SummaryADI study watch python SDK
upload_time2023-06-06 11:08:18
maintainer
docs_urlNone
authorAnalog Devices, Inc.
requires_python>=3.6
licenseApache License, Version 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Study Watch Python SDK

The adi-study-watch provides an object-oriented interface for interacting with ADI's VSM study watch platform.

**Installation**

```python
pip install adi-study-watch
```
**Description**

A user application can use the SDK to receive complete packets of bytes over a physical interface (USB or BLE) and
decode it. The functionality is organized into applications, some of which own sensors, some own system-level
functionality (i.e. file system), and while others own algorithms. The hierarchy of objects within the SDK mirrors the
applications present on the device. Each application has its own object within the SDK hierarchy, which is used to
interact with that application. A brief guide on using the SDK and few examples have been added below.

**Firmware Setup**

https://github.com/analogdevicesinc/study-watch-sdk/blob/main/firmware/Study_Watch_Firmware_Upgrade.pdf

**Getting started with SDK**

Import the adi-study-watch module into your application code
```python
from adi_study_watch import SDK
```
Instantiate the SDK object by passing the com port number
```python
sdk = SDK('COM28')
```
The application objects can be instantiated from the sdk object. In order to instantiate an application object, we'll
have to pass a call-back function as an input argument which can be used to retrieve the data from the application
object. Define a callback function as displayed below.
```python
def adxl_cb(data):
    print(data)
```
Once the call-back function is defined, you can instantiate the application object as shown below.
```python
adxl_app = sdk.get_adxl_application()
adxl_app.set_callback(adxl_cb)
```
Each application object has various methods that can be called by referring to the application. An example of retrieving
the sensor status is shown below. Almost all method in an application returns result in a dict.

```python
packet = adxl_app.get_sensor_status() # returns dict
print(packet)
```

**Basic Example:**

```python
import time
from datetime import datetime
from adi_study_watch import SDK

# callback function to receive adxl data
def callback_data(data):
    sequence_number = data["payload"]["sequence_number"]
    for stream_data in data["payload"]["stream_data"]:
        dt_object = datetime.fromtimestamp(stream_data['timestamp'] / 1000)  # convert timestamp from ms to sec.
        print(f"seq :{sequence_number} timestamp: {dt_object} x,y,z :: ({stream_data['x']}, "
              f"{stream_data['y']}, {stream_data['z']})")


if __name__ == "__main__":
    sdk = SDK("COM4")
    application = sdk.get_adxl_application()
    application.set_callback(callback_data)

    # quickstart adxl stream
    application.start_sensor()
    application.enable_csv_logging("adxl.csv") # logging adxl data to csv file
    application.subscribe_stream()
    time.sleep(10)
    application.unsubscribe_stream()
    application.disable_csv_logging()
    application.stop_sensor()
```

# Permission Issue in Ubuntu

1 - You can run your script with admin (sudo).

2 - If you don't want to run scripts as admin follows the steps below:

- add user to `tty` and `dialout` group

```
sudo usermod -aG tty <user>
sudo usermod -aG dialout <user>
```
- create a file at `/etc/udev/rules.d/` with name `10-adi-usb.rules`:
```
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="2cfe", MODE="0666", GROUP="dialout"
```
- reboot

**All streams packet structure :**
https://analogdevicesinc.github.io/study-watch-sdk/python/_rst/adi_study_watch.core.packets.html#module-adi_study_watch.core.packets.stream_data_packets

**Documentation :**
https://analogdevicesinc.github.io/study-watch-sdk/python

**Examples :**
https://github.com/analogdevicesinc/study-watch-sdk/tree/main/python/samples

**License :**
https://github.com/analogdevicesinc/study-watch-sdk/blob/main/LICENSE

**Changelog**
https://github.com/analogdevicesinc/study-watch-sdk/blob/main/python/CHANGELOG.md


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/analogdevicesinc/study-watch-sdk",
    "name": "adi-study-watch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Analog Devices, Inc.",
    "author_email": "healthcare-support@analog.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/94/ae404d0c75d12c915f09b810681f516828210699b566ebc24d1efec85497/adi_study_watch-5.20.0.tar.gz",
    "platform": null,
    "description": "# Study Watch Python SDK\r\n\r\nThe adi-study-watch provides an object-oriented interface for interacting with ADI's VSM study watch platform.\r\n\r\n**Installation**\r\n\r\n```python\r\npip install adi-study-watch\r\n```\r\n**Description**\r\n\r\nA user application can use the SDK to receive complete packets of bytes over a physical interface (USB or BLE) and\r\ndecode it. The functionality is organized into applications, some of which own sensors, some own system-level\r\nfunctionality (i.e. file system), and while others own algorithms. The hierarchy of objects within the SDK mirrors the\r\napplications present on the device. Each application has its own object within the SDK hierarchy, which is used to\r\ninteract with that application. A brief guide on using the SDK and few examples have been added below.\r\n\r\n**Firmware Setup**\r\n\r\nhttps://github.com/analogdevicesinc/study-watch-sdk/blob/main/firmware/Study_Watch_Firmware_Upgrade.pdf\r\n\r\n**Getting started with SDK**\r\n\r\nImport the adi-study-watch module into your application code\r\n```python\r\nfrom adi_study_watch import SDK\r\n```\r\nInstantiate the SDK object by passing the com port number\r\n```python\r\nsdk = SDK('COM28')\r\n```\r\nThe application objects can be instantiated from the sdk object. In order to instantiate an application object, we'll\r\nhave to pass a call-back function as an input argument which can be used to retrieve the data from the application\r\nobject. Define a callback function as displayed below.\r\n```python\r\ndef adxl_cb(data):\r\n    print(data)\r\n```\r\nOnce the call-back function is defined, you can instantiate the application object as shown below.\r\n```python\r\nadxl_app = sdk.get_adxl_application()\r\nadxl_app.set_callback(adxl_cb)\r\n```\r\nEach application object has various methods that can be called by referring to the application. An example of retrieving\r\nthe sensor status is shown below. Almost all method in an application returns result in a dict.\r\n\r\n```python\r\npacket = adxl_app.get_sensor_status() # returns dict\r\nprint(packet)\r\n```\r\n\r\n**Basic Example:**\r\n\r\n```python\r\nimport time\r\nfrom datetime import datetime\r\nfrom adi_study_watch import SDK\r\n\r\n# callback function to receive adxl data\r\ndef callback_data(data):\r\n    sequence_number = data[\"payload\"][\"sequence_number\"]\r\n    for stream_data in data[\"payload\"][\"stream_data\"]:\r\n        dt_object = datetime.fromtimestamp(stream_data['timestamp'] / 1000)  # convert timestamp from ms to sec.\r\n        print(f\"seq :{sequence_number} timestamp: {dt_object} x,y,z :: ({stream_data['x']}, \"\r\n              f\"{stream_data['y']}, {stream_data['z']})\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    sdk = SDK(\"COM4\")\r\n    application = sdk.get_adxl_application()\r\n    application.set_callback(callback_data)\r\n\r\n    # quickstart adxl stream\r\n    application.start_sensor()\r\n    application.enable_csv_logging(\"adxl.csv\") # logging adxl data to csv file\r\n    application.subscribe_stream()\r\n    time.sleep(10)\r\n    application.unsubscribe_stream()\r\n    application.disable_csv_logging()\r\n    application.stop_sensor()\r\n```\r\n\r\n# Permission Issue in Ubuntu\r\n\r\n1 - You can run your script with admin (sudo).\r\n\r\n2 - If you don't want to run scripts as admin follows the steps below:\r\n\r\n- add user to `tty` and `dialout` group\r\n\r\n```\r\nsudo usermod -aG tty <user>\r\nsudo usermod -aG dialout <user>\r\n```\r\n- create a file at `/etc/udev/rules.d/` with name `10-adi-usb.rules`:\r\n```\r\nACTION==\"add\", SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0456\", ATTRS{idProduct}==\"2cfe\", MODE=\"0666\", GROUP=\"dialout\"\r\n```\r\n- reboot\r\n\r\n**All streams packet structure :**\r\nhttps://analogdevicesinc.github.io/study-watch-sdk/python/_rst/adi_study_watch.core.packets.html#module-adi_study_watch.core.packets.stream_data_packets\r\n\r\n**Documentation :**\r\nhttps://analogdevicesinc.github.io/study-watch-sdk/python\r\n\r\n**Examples :**\r\nhttps://github.com/analogdevicesinc/study-watch-sdk/tree/main/python/samples\r\n\r\n**License :**\r\nhttps://github.com/analogdevicesinc/study-watch-sdk/blob/main/LICENSE\r\n\r\n**Changelog**\r\nhttps://github.com/analogdevicesinc/study-watch-sdk/blob/main/python/CHANGELOG.md\r\n\r\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "ADI study watch python SDK",
    "version": "5.20.0",
    "project_urls": {
        "Homepage": "https://github.com/analogdevicesinc/study-watch-sdk"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32c0e1adb38c1989dbb4dbe59116a23c6fb03056e30f96d18e562412534559a8",
                "md5": "e090fc0b353b964e0bd61b1c32e21db0",
                "sha256": "2b7e24157d2652adfa207c732c5e449f0a2f3e39851122980ca4d91e6c33bebc"
            },
            "downloads": -1,
            "filename": "adi_study_watch-5.20.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e090fc0b353b964e0bd61b1c32e21db0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 204089,
            "upload_time": "2023-06-06T11:08:16",
            "upload_time_iso_8601": "2023-06-06T11:08:16.438668Z",
            "url": "https://files.pythonhosted.org/packages/32/c0/e1adb38c1989dbb4dbe59116a23c6fb03056e30f96d18e562412534559a8/adi_study_watch-5.20.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e394ae404d0c75d12c915f09b810681f516828210699b566ebc24d1efec85497",
                "md5": "32fd438e301478c20c15e92f1a9bbaab",
                "sha256": "4e1c4f572e78b7182992bd050e9757049d27b4b5b7f6841f91acca64b0187871"
            },
            "downloads": -1,
            "filename": "adi_study_watch-5.20.0.tar.gz",
            "has_sig": false,
            "md5_digest": "32fd438e301478c20c15e92f1a9bbaab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 115230,
            "upload_time": "2023-06-06T11:08:18",
            "upload_time_iso_8601": "2023-06-06T11:08:18.541374Z",
            "url": "https://files.pythonhosted.org/packages/e3/94/ae404d0c75d12c915f09b810681f516828210699b566ebc24d1efec85497/adi_study_watch-5.20.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-06 11:08:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "analogdevicesinc",
    "github_project": "study-watch-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "adi-study-watch"
}
        
Elapsed time: 0.13642s