Feature/v0.2.2 (#10)
* init v.0.2.2 * v0.2.2 added support for rs485 to tcp adapter
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -173,3 +173,4 @@ cython_debug/
|
||||
prot.csv
|
||||
helpertils/serial.py
|
||||
helpertils/test.py
|
||||
helpertils/socker.py
|
||||
|
||||
21
EHSConfig.py
21
EHSConfig.py
@@ -25,6 +25,7 @@ class EHSConfig():
|
||||
MQTT = None
|
||||
GENERAL = None
|
||||
SERIAL = None
|
||||
TCP = None
|
||||
NASA_REPO = None
|
||||
LOGGING = {}
|
||||
|
||||
@@ -77,7 +78,13 @@ class EHSConfig():
|
||||
config = yaml.safe_load(file)
|
||||
self.MQTT = config.get('mqtt')
|
||||
self.GENERAL = config.get('general')
|
||||
|
||||
if 'tcp' in config:
|
||||
self.TCP = config.get('tcp')
|
||||
|
||||
if 'serial' in config:
|
||||
self.SERIAL = config.get('serial')
|
||||
|
||||
if 'logging' in config:
|
||||
self.LOGGING = config.get('logging')
|
||||
else:
|
||||
@@ -106,12 +113,26 @@ class EHSConfig():
|
||||
if 'protocolFile' not in self.GENERAL:
|
||||
self.GENERAL['protocolFile'] = None
|
||||
|
||||
if self.SERIAL is None and self.TCP is None:
|
||||
raise ConfigException(argument="", message="define tcp or serial config parms")
|
||||
|
||||
if self.SERIAL is not None and self.TCP is not None:
|
||||
raise ConfigException(argument="", message="you cannot define tcp and serial please define only one")
|
||||
|
||||
if self.SERIAL is not None:
|
||||
if 'device' not in self.SERIAL:
|
||||
raise ConfigException(argument=self.SERIAL['device'], message="serial device config parameter is missing")
|
||||
|
||||
if 'baudrate' not in self.SERIAL:
|
||||
raise ConfigException(argument=self.SERIAL['baudrate'], message="serial baudrate config parameter is missing")
|
||||
|
||||
if self.TCP is not None:
|
||||
if 'ip' not in self.TCP:
|
||||
raise ConfigException(argument=self.TCP['ip'], message="tcp ip config parameter is missing")
|
||||
|
||||
if 'port' not in self.TCP:
|
||||
raise ConfigException(argument=self.TCP['port'], message="tcp port config parameter is missing")
|
||||
|
||||
if 'broker-url' not in self.MQTT:
|
||||
raise ConfigException(argument=self.MQTT['broker-url'], message="mqtt broker-url config parameter is missing")
|
||||
|
||||
|
||||
23
README.md
23
README.md
@@ -184,12 +184,21 @@ The `config.yml` file contains configuration settings for the EHS-Sentinel proje
|
||||
- Default: `False`
|
||||
|
||||
### Serial Connection Settings
|
||||
cannot be defined with TCP parm...
|
||||
|
||||
- **device**: The serial device URL.
|
||||
- Example: `/dev/ttyUSB0`
|
||||
- **baudrate**: The baud rate for the serial connection.
|
||||
- Example: `9600`
|
||||
|
||||
### TCP Settings
|
||||
cannot be defined with SERIAL parm...
|
||||
|
||||
- **ip**: The ip of rs485 to ETH Adapter.
|
||||
- Example: `168.192.2.200`
|
||||
- **port**: The port of rs485 to ETH Adapter.
|
||||
- Example: `4196`
|
||||
|
||||
### MQTT Broker Settings
|
||||
|
||||
- **broker-url**: The URL of the MQTT broker.
|
||||
@@ -214,15 +223,18 @@ The `config.yml` file contains configuration settings for the EHS-Sentinel proje
|
||||
```yaml
|
||||
general:
|
||||
nasaRepositoryFile: data/NasaRepository.yml
|
||||
protocolFile: prot.csv
|
||||
# protocolFile: prot.csv
|
||||
logging:
|
||||
deviceAdded: True
|
||||
messageNotFound: False
|
||||
packetNotFromIndoorOutdoor: False
|
||||
proccessedMessage: False
|
||||
serial:
|
||||
device: /dev/ttyUSB0
|
||||
baudrate: 9600
|
||||
#serial:
|
||||
# device: /dev/ttyUSB0
|
||||
# baudrate: 9600
|
||||
tcp:
|
||||
ip: 168.192.2.200
|
||||
port: 4196
|
||||
mqtt:
|
||||
broker-url: 123.45.6.69
|
||||
broker-port: 1883
|
||||
@@ -267,6 +279,9 @@ if you want to see how many uniquie Messages have been collected in the Dumpfile
|
||||
|
||||
# Changelog
|
||||
|
||||
### v0.2.2 - 2025-02-24
|
||||
- Support for rs485 to ETH Adapter, tcp options instead of serial port are possible now
|
||||
|
||||
### v0.2.1 - 2025-02-22
|
||||
- limit NASA_EHSSENTINEL_COP and NASA_EHSSENTINEL_TOTAL_COP to values between 0 and 20
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ logging:
|
||||
serial:
|
||||
device: /dev/ttyUSB0
|
||||
baudrate: 9600
|
||||
tcp:
|
||||
ip: 168.192.2.200
|
||||
port: 4196
|
||||
mqtt:
|
||||
broker-url: 111.111.11.1
|
||||
broker-port: 1883
|
||||
|
||||
@@ -115,26 +115,21 @@ async def serial_connection(config, args):
|
||||
"""
|
||||
Asynchronously reads data from a serial connection and processes it.
|
||||
Args:
|
||||
config (object): Configuration object containing serial connection parameters.
|
||||
config (object): Configuration object containing serial or tcp connection parameters.
|
||||
args (object): Additional arguments for buffer processing.
|
||||
This function establishes a serial connection using parameters from the config object,
|
||||
reads data from the serial port until a specified delimiter (0x34) is encountered,
|
||||
This function establishes a serial or tcp connection using parameters from the config object,
|
||||
reads data from the serial port or tcp port until a specified delimiter (0x34) is encountered,
|
||||
and appends the received data to a buffer. It also starts an asynchronous task to
|
||||
process the buffer.
|
||||
The serial connection is configured with the following parameters:
|
||||
- Device URL: config.SERIAL['device']
|
||||
- Baudrate: config.SERIAL['baudrate']
|
||||
- Parity: Even
|
||||
- Stopbits: One
|
||||
- Bytesize: Eight
|
||||
- RTS/CTS flow control: Enabled
|
||||
- Timeout: 0
|
||||
The function runs an infinite loop to continuously read data from the serial port.
|
||||
The function runs an infinite loop to continuously read data from the serial port/tcp port.
|
||||
"""
|
||||
|
||||
buffer = []
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
if config.TCP is not None:
|
||||
reader, writer = await asyncio.open_connection(config.TCP['ip'], config.TCP['port'])
|
||||
else:
|
||||
reader, writer = await serial_asyncio.open_serial_connection(
|
||||
loop=loop,
|
||||
url=config.SERIAL['device'],
|
||||
|
||||
Reference in New Issue
Block a user