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 details)

Uploaded Source

File details

Details for the file pydevmgr_serial-0.5.0.tar.gz.

File metadata

  • Download URL: pydevmgr_serial-0.5.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.4.2 requests/2.25.1 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for pydevmgr_serial-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e5a3e8bfa6af0e1f85f1b9fc69c7033887b8c646b1da988ee9272a22a05f7edf
MD5 5e013267d668c0900bfd40c96da3be9e
BLAKE2b-256 11018a7892cd4c5a5efade69609b72e607924c60ab2839d9914d57efc699b110

See more details on using hashes here.

Supported by

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