Low-effort serial communication, e.g. for talking to devices that use the Arduino-IDE Keyhole library
Project description
This module provides the Keyhole class, which allows easy line-by-line text communication over a serial port. It is particularly useful for implementing the computer’s side of the interaction when talking to a microcontroller that has been programmed using the Arduino- IDE Keyhole library. In that case, exposed sketch variables can be accessed as attributes of a Keyhole instance in Python.
The Arduino side:
#include "Keyhole.h"
Keyhole k;
void setup()
{
Serial.begin(9600);
}
void loop()
{
static float foo = 1.23;
static String bar = "hello";
// insert main sketch logic here (use foo and bar to do whatever is so important)
if(k.begin()) // expose the variables
{
k.variable("foo", foo);
k.variable("bar", bar);
k.end();
}
}
The Python side:
from keyhole import Keyhole
# k = Keyhole('COM4') # windows example
k = Keyhole('/dev/cu.usbmodem[0-9]*') # macos example (globbing is OK if the match is unique)
print( k.bar ) # queries an exposed sketch variable
k.foo = 4.56 # assigns to an exposed sketch variable and makes the .variable() call return true
print( k() ) # get all exposed variables
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keyhole_comm-1.10.0-py2.py3-none-any.whl.
File metadata
- Download URL: keyhole_comm-1.10.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39393f6340b4a234e24d3d3d7f04168a2c7495eab18e629d36613e4761315a7a
|
|
| MD5 |
0d6c47bc399d6c146d41f23a41f96787
|
|
| BLAKE2b-256 |
cde68e94c4417189199279f4facc9878e6afe6467da5092b880da19c504917bd
|