Skip to main content

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


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.5.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

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