No project description provided
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, SerialCom
import time
class TesaNodeConfig(BaseSerialNode.Config):
type : 'Tesa'
delay: float = 0.1
class TesaNode(BaseSerialNode):
Config = TesaNodeConfig
def fget(self):
self.com.serial.write(b'?\r')
time.sleep(self.config.delay)
sval = self.com.serial.read(20)
val = float(sval)
return val
# build a standalone node
tesa_com = SerialCom(port='COM1', baudrate=9600)
tesa = TesaNode(com=tesa_com)
try:
tesa_com.connect()
print( "Position is ", tesa.get() )
finally:
tesa_com.disconnect()
One can include the node in device
from pydevmgr_serial import BaseSerialDevice
from pydevmgr_core import NodeAlias
class Tesa(BaseSerialDevice):
raw_pos = TesaNode.Prop('raw_pos')
@NodeAlias.prop('scaled_pos',['raw_pos'])
def scaled_pos(self, raw_pos):
return 10 + 1.3 * raw_pos
tesa = Tesa('tesa', com={'port':'COM1'})
tesa.connect()
tesa.scaled_pos.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.3.tar.gz
(4.6 kB
view hashes)
Built Distribution
pydevmgr_serial-0.3-py3.7.egg
(14.3 kB
view hashes)