Skip to main content

Python library for Water Linked underwater modems

Project description

Python library for Water Linked underwater modems

PyPI version

Python library for communicating with Water Linked underwater modems.

The library exposes the functionality of the modem: setting configuration, getting diagnostic, sending and receiving packets.

Resources

Requirements

  • Python 2.7 or Python 3.6
  • pyserial
  • crcmod

Supported modems

  • Water Linked Modem-M64

Setup

$ python3 -m pip install --user wlmodem
or
(venv)$ python3 -m pip install wlmodem

Quick start

Connecting to a modem and configuring the mode and channel:

$ python3

>>>  from wlmodem import WlModem
>>>  modem = WlModem("/dev/ttyUSB0")
>>>  modem.connect()
True
>>>  modem.cmd_configure("a", 4)
True
>>>  modem.cmd_queue_packet(b"HelloSea")
True

Usage

The WlModem class provides an easy interface to configure, send and receive data with a Water Linked modem. A pair of modems must be configured on the same channel and with different roles to establish communication between them.

A WlModem object is initialized with the serial device name:

from wlmodem import WlModem
modem = WlModem("/dev/ttyUSB0")

Call connect() to establish communication with the device

if not modem.connect():
    print("Failed connecting to modem")
    sys.exit(1)

Once connected we set the same channel and different roles on the pair of modems:

# On modem 1:
success = modem.cmd_configure("a", 4)
# On modem 2:
success = modem.cmd_configure("b", 4)

If the tip of the modems are close to each other (<5cm) the modems will now link up. The link status can be seen on the LEDs or by getting the diagnostic data.

if modem.cmd_get_diagnostic().get("link_up"):
    print("Link is up")

Once we have connected we can use cmd_queue_packet function to queue data for transmission.

success = modem.cmd_queue_packet(b"HelloSea")

In order to get data which one modem has received from the other modem use the get_data_packet function. This function will by default wait timeout seconds until a data packet is received before returning. If timeout is 0 it will immediately return with a packet (if available) or None if no packet has been received.

pkt = modem.get_data_packet(timeout=0)
if pkt:
    print("Got data:", pkt)

Example

A larger example is available in example/example.py.

Development

The code in this repository is unit tested with pytest. tox is used to automate testing on multiple Python versions.

Run unit-tests with:

pip install tox
tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wlmodem-1.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wlmodem-1.0.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file wlmodem-1.0.1.tar.gz.

File metadata

  • Download URL: wlmodem-1.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for wlmodem-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2f08c0eb9dbd2b7c2f05407d844964b05aac1e16be7e61d323a4361bfcecab81
MD5 5451252aca22746b5930a5c5b9db2f86
BLAKE2b-256 70b3d553adfa1d63bd2e4294eca2666e03eea2424099b0ce8d8d8779b15d1569

See more details on using hashes here.

File details

Details for the file wlmodem-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: wlmodem-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for wlmodem-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b685371ec1ff2c0edc174bff77cd94f68cf7efad2368e58dba089671798654e2
MD5 8bd945aa07e38fd50880f9be2c4a806e
BLAKE2b-256 938aa1603471f62b8bc030d70b40a41257f8aa457bc0a84ad09653b57eef8901

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page