based pydevmgr object for serial communication
Project description
An pydevmgr_core extension for serial communication
Sources are here
Doc to comme
Install
> pip install pydevmgr_serial
Basic Usage
Bellow is an exemple of implementation of a node that check a value from a Tesla Sensor. An extra configuration argument is added and the fget method is implemented.
from pydevmgr_serial import BaseSerialNode
import time
class TesaNode(BaseSerialNode):
class Config:
delay: float = 0.1
def fget(self):
self.serial.write(b'?\r')
time.sleep(self.config.delay)
sval = self.serial.read(20)
val = float(sval)
return val
you can simply use the node with a Serial object :
from serial import Serial
# build a standalone node
com = Serial(port='COM1', baudrate=9600)
tesa = TesaNode(com=com)
print( "Position is ", tesa.get() )
com.close()
One can include the node in a serial device which will hold the communcation
Note: One creating a SerialDevice the port is not directly opened one needs to use
the connect
method or within a with statement.
from pydevmgr_serial import SerialDevice
from pydevmgr_core import nodealias
class Tesa(SerialDevice):
raw_pos = TesaNode.Config()
@nodealias('raw_pos')
def position(self, raw_pos):
return 10 + 1.3 * raw_pos
tesa = Tesa('tesa', port ='COM1', baudrate=9600)
with tesa:
tesa.position.get()
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 Distribution
pydevmgr_serial-0.6a0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for pydevmgr_serial-0.6a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 592959ba406a87db98445cc82c134470ed00ec2e2dc067ba8fb008fe15a66987 |
|
MD5 | 7cbbba2061aa15e898ace992b364f704 |
|
BLAKE2b-256 | bcf48be3fb8e8950024e0ce91b84c374e30ab396fde98d020d4d1c4973f4be8b |