28 lines
775 B
Python
28 lines
775 B
Python
# tool/core/cmd/proto.py
|
|
import struct
|
|
from core.utils import console, console_err
|
|
from core.protocol import COMMANDS, ERRORS
|
|
|
|
class proto:
|
|
def __init__(self, bus):
|
|
self.bus = bus
|
|
|
|
def get(self):
|
|
self.bus.send_request(COMMANDS['get_protocol_version'], None)
|
|
|
|
data = self.bus.receive_response(length=1)
|
|
if not data or data.get('type') == 'error':
|
|
return None
|
|
|
|
payload = data['data']
|
|
result = {
|
|
'protocol_version': payload[0]
|
|
}
|
|
return result
|
|
|
|
def print(self, result):
|
|
if not result:
|
|
return
|
|
|
|
protocol_version = result['protocol_version']
|
|
console.print(f"[title]Protokoll Version[/info] des Controllers ist [info]{protocol_version}[/info]:") |