Metadata-Version: 2.1
Name: pydevmgr-serial
Version: 0.6a0
Summary: based pydevmgr object for serial communication
License: CECILL-2.1
Author: Sylvain Guieu
Author-email: sylvain.guieu@univ-grenoble-alpes.fr
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: pydevmgr-core (==0.6.a0)
Requires-Dist: pyserial (>=3.5,<4.0)
Description-Content-Type: text/markdown

An pydevmgr_core extension for serial communication 



Sources are [here](https://github.com/efisoft-elt/pydevmgr_serial) 

Doc to comme


# Install

```bash
> 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. 

```python 
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 :

```python 
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. 


```python 
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    
```

```python 
tesa = Tesa('tesa',  port ='COM1', baudrate=9600)

with tesa:
    tesa.position.get()
```




