Commit 7615de5a authored by Federico Sismondi's avatar Federico Sismondi
Browse files

fixed comments, added some ASCII art

parent 36f211f5
......@@ -13,6 +13,39 @@ __version__ = (0, 0, 1)
log = logging.getLogger(__name__)
finteorp_banner = \
"""
______ _____ _
| ____| |_ _| | |
| |__ ______| | _ __ | |_ ___ _ __ ___ _ __
| __|______| | | '_ \| __/ _ \ '__/ _ \| '_ \
| | _| |_| | | | || __/ | | (_) | |_) |
|_| |_____|_| |_|\__\___|_| \___/| .__/
| |
|_|
"""
arrow_down = """
___
| | _ _ _
| | | (_) | |
| | _ _ _ __ | |_ _ __ | | __
| | | | | | '_ \| | | '_ \| |/ /
| | | |_| | |_) | | | | | | <
| | \__,_| .__/|_|_|_| |_|_|\_\
| | | |
| | |_|
__! !__,
\ / \O
\ / \/|
\ / |
\ / / \
Y _/ _\
"""
class SerialConsumer(BaseConsumer):
"""
......@@ -48,7 +81,7 @@ class SerialConsumer(BaseConsumer):
}
serial_listener = SerialListener(**params)
serial_listener_th = threading.Thread(target=serial_listener.run, args=())
serial_listener_th.daemon=True
serial_listener_th.daemon = True
serial_listener_th.start()
......@@ -58,8 +91,6 @@ class SerialConsumer(BaseConsumer):
'FINTEROP_CONNECTOR_SERIAL_PORT/FINTEROP_CONNECTOR_BAUDRATE '
'If no sniffer/injector needed for test ignore this warning ')
def handle_data(self, body, message):
"""
Function that will handle serial management messages
......@@ -101,8 +132,9 @@ class SerialConsumer(BaseConsumer):
except:
log.error('Error while tring to write serial interface')
print(arrow_down)
log.info('\n # # # # # # # # # # # # SERIAL INTERFACE # # # # # # # # # # # # ' +
'\n data packet SERIAL -> EventBus' +
'\n data packet EventBus -> Serial' +
'\n' + json.dumps(body) +
'\n # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # '
)
......
......@@ -8,6 +8,7 @@ import time
import signal
import sys
from kombu import Exchange
from collections import OrderedDict
......@@ -23,6 +24,31 @@ logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
arrow_up = """
_
/ \
/ \
/ \
/ \
/__ __\
| | _ _ _
| | | (_) | |
| | _ _ _ __ | |_ _ __ | | __
| | | | | | '_ \| | | '_ \| |/ /
| | | |_| | |_) | | | | | | <
| | \__,_| .__/|_|_|_| |_|_|\_\
| | | |
| | |_|
!___!
\ O /
\/|\/
|
/ \
_/ \ _
"""
class SerialListener(object):
def __init__(self, agent_name, rmq_connection, rmq_exchange="amq.topic", serial_port='/dev/ttyUSB0',
serial_boudrate='460800'):
......@@ -133,9 +159,9 @@ class SerialListener(object):
self.producer.publish(body,
exchange=self.exchange,
routing_key=self.mrkey)
print(arrow_up)
log.info('\n # # # # # # # # # # # # SERIAL INTERFACE # # # # # # # # # # # # ' +
'\n data packet SERIAL -> EventBus' +
'\n data packet Serial -> EventBus' +
'\n' + json.dumps(body) +
'\n # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # '
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment