mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-20 11:17:58 +00:00
Rebrand project to PiSCSI (#1016)
* Rebrand project to PiSCSI - rascsi ->piscsi - rasctl -> scsictl - rasdump -> scsidump - ras* -> piscsi* (rasutil -> piscsi_util, etc.) * Refined the formatting and wording of the app startup banner * Kept some references to rascsi and rasctl where backwards compatibility is concerned * Point to the new github repo URL Co-authored-by: nucleogenic <nr@nucleogenic.com> Co-authored-by: Uwe Seimet <Uwe.Seimet@seimet.de>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# RaSCSI Control Board UI
|
||||
# PiSCSI Control Board UI
|
||||
|
||||
## Run as standalone script for development / troubleshooting
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=PiSCSI Control Board service
|
||||
After=network.target piscsi.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=2s
|
||||
ExecStart=/home/pi/piscsi/python/ctrlboard/start.sh
|
||||
ExecStop=/bin/pkill --signal 2 -f "python3 src/main.py"
|
||||
SyslogIdentifier=PISCSICTRLB
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=RaSCSI Control Board service
|
||||
After=network.target rascsi.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=2s
|
||||
ExecStart=/home/pi/RASCSI/python/ctrlboard/start.sh
|
||||
ExecStop=/bin/pkill --signal 2 -f "python3 src/main.py"
|
||||
SyslogIdentifier=RASCSICTRLB
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,12 +1,12 @@
|
||||
"""
|
||||
Module for central RaSCSI control board configuration parameters
|
||||
Module for central PiSCSI control board configuration parameters
|
||||
"""
|
||||
from ctrlboard_hw.ctrlboard_hw_constants import CtrlBoardHardwareConstants
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class CtrlboardConfig:
|
||||
"""Class for central RaSCSI control board configuration parameters"""
|
||||
"""Class for central PiSCSI control board configuration parameters"""
|
||||
|
||||
ROTATION = 0
|
||||
WIDTH = 128
|
||||
@@ -20,8 +20,8 @@ class CtrlboardConfig:
|
||||
MENU_REFRESH_INTERVAL = 6
|
||||
LOG_LEVEL = 30 # Warning
|
||||
|
||||
RASCSI_HOST = "localhost"
|
||||
RASCSI_PORT = "6868"
|
||||
PISCSI_HOST = "localhost"
|
||||
PISCSI_PORT = "6868"
|
||||
|
||||
def __str__(self):
|
||||
result = "rotation: " + str(self.ROTATION) + "\n"
|
||||
@@ -29,8 +29,8 @@ class CtrlboardConfig:
|
||||
result += "height: " + str(self.HEIGHT) + "\n"
|
||||
result += "lines: " + str(self.LINES) + "\n"
|
||||
result += "border: " + str(self.BORDER) + "\n"
|
||||
result += "rascsi host: " + str(self.RASCSI_HOST) + "\n"
|
||||
result += "rascsi port: " + str(self.RASCSI_PORT) + "\n"
|
||||
result += "piscsi host: " + str(self.PISCSI_HOST) + "\n"
|
||||
result += "piscsi port: " + str(self.PISCSI_PORT) + "\n"
|
||||
result += "transitions: " + str(self.TRANSITIONS) + "\n"
|
||||
|
||||
return result
|
||||
|
||||
+35
-35
@@ -1,38 +1,38 @@
|
||||
"""Module for interfacing between the menu controller and the RaSCSI Control Board hardware"""
|
||||
"""Module for interfacing between the menu controller and the PiSCSI Control Board hardware"""
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from ctrlboard_event_handler.rascsi_profile_cycler import RascsiProfileCycler
|
||||
from ctrlboard_event_handler.rascsi_shutdown_cycler import RascsiShutdownCycler
|
||||
from ctrlboard_event_handler.piscsi_profile_cycler import PiscsiProfileCycler
|
||||
from ctrlboard_event_handler.piscsi_shutdown_cycler import PiscsiShutdownCycler
|
||||
from ctrlboard_menu_builder import CtrlBoardMenuBuilder
|
||||
from ctrlboard_hw.ctrlboard_hw_constants import CtrlBoardHardwareConstants
|
||||
from ctrlboard_hw.hardware_button import HardwareButton
|
||||
from ctrlboard_hw.encoder import Encoder
|
||||
from observer import Observer
|
||||
from rascsi.file_cmds import FileCmds
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
from rascsi.socket_cmds import SocketCmds
|
||||
from rascsi_menu_controller import RascsiMenuController
|
||||
from piscsi.file_cmds import FileCmds
|
||||
from piscsi.piscsi_cmds import PiscsiCmds
|
||||
from piscsi.socket_cmds import SocketCmds
|
||||
from piscsi_menu_controller import PiscsiMenuController
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
"""Class interfacing the menu controller the RaSCSI Control Board hardware."""
|
||||
"""Class interfacing the menu controller the PiSCSI Control Board hardware."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
menu_controller: RascsiMenuController,
|
||||
menu_controller: PiscsiMenuController,
|
||||
sock_cmd: SocketCmds,
|
||||
ractl_cmd: RaCtlCmds,
|
||||
piscsi_cmd: PiscsiCmds,
|
||||
):
|
||||
self.message = None
|
||||
self._menu_controller = menu_controller
|
||||
self._menu_renderer_config = self._menu_controller.get_menu_renderer().get_config()
|
||||
self.sock_cmd = sock_cmd
|
||||
self.ractl_cmd = ractl_cmd
|
||||
self.piscsi_cmd = piscsi_cmd
|
||||
self.context_stack = []
|
||||
self.rascsi_profile_cycler: Optional[RascsiProfileCycler] = None
|
||||
self.rascsi_shutdown_cycler: Optional[RascsiShutdownCycler] = None
|
||||
self.piscsi_profile_cycler: Optional[PiscsiProfileCycler] = None
|
||||
self.piscsi_shutdown_cycler: Optional[PiscsiShutdownCycler] = None
|
||||
|
||||
def update(self, updated_object):
|
||||
if isinstance(updated_object, HardwareButton):
|
||||
@@ -62,35 +62,35 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
|
||||
def update_events(self):
|
||||
"""Method handling non-blocking event handling for the cycle buttons."""
|
||||
if self.rascsi_profile_cycler is not None:
|
||||
result = self.rascsi_profile_cycler.update()
|
||||
if self.piscsi_profile_cycler is not None:
|
||||
result = self.piscsi_profile_cycler.update()
|
||||
if result is not None:
|
||||
self.rascsi_profile_cycler = None
|
||||
self.piscsi_profile_cycler = None
|
||||
self.context_stack = []
|
||||
self._menu_controller.segue(result)
|
||||
if self.rascsi_shutdown_cycler is not None:
|
||||
self.rascsi_shutdown_cycler.empty_messages = False
|
||||
result = self.rascsi_shutdown_cycler.update()
|
||||
if self.piscsi_shutdown_cycler is not None:
|
||||
self.piscsi_shutdown_cycler.empty_messages = False
|
||||
result = self.piscsi_shutdown_cycler.update()
|
||||
if result == "return":
|
||||
self.rascsi_shutdown_cycler = None
|
||||
self.piscsi_shutdown_cycler = None
|
||||
|
||||
def handle_button1(self):
|
||||
"""Method for handling the first cycle button (cycle profiles)"""
|
||||
if self.rascsi_profile_cycler is None:
|
||||
self.rascsi_profile_cycler = RascsiProfileCycler(
|
||||
self._menu_controller, self.sock_cmd, self.ractl_cmd, return_entry=True
|
||||
if self.piscsi_profile_cycler is None:
|
||||
self.piscsi_profile_cycler = PiscsiProfileCycler(
|
||||
self._menu_controller, self.sock_cmd, self.piscsi_cmd, return_entry=True
|
||||
)
|
||||
else:
|
||||
self.rascsi_profile_cycler.cycle()
|
||||
self.piscsi_profile_cycler.cycle()
|
||||
|
||||
def handle_button2(self):
|
||||
"""Method for handling the second cycle button (cycle shutdown)"""
|
||||
if self.rascsi_shutdown_cycler is None:
|
||||
self.rascsi_shutdown_cycler = RascsiShutdownCycler(
|
||||
self._menu_controller, self.sock_cmd, self.ractl_cmd
|
||||
if self.piscsi_shutdown_cycler is None:
|
||||
self.piscsi_shutdown_cycler = PiscsiShutdownCycler(
|
||||
self._menu_controller, self.sock_cmd, self.piscsi_cmd
|
||||
)
|
||||
else:
|
||||
self.rascsi_shutdown_cycler.cycle()
|
||||
self.piscsi_shutdown_cycler.cycle()
|
||||
|
||||
def route_rotary_button_handler(self, info_object):
|
||||
"""Method for handling the rotary button press for the menu navigation"""
|
||||
@@ -195,7 +195,7 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
"""Method handles the rotary button press in the profile selection menu
|
||||
for selecting a profile to load."""
|
||||
if info_object is not None and "name" in info_object:
|
||||
file_cmd = FileCmds(sock_cmd=self.sock_cmd, ractl=self.ractl_cmd)
|
||||
file_cmd = FileCmds(sock_cmd=self.sock_cmd, piscsi=self.piscsi_cmd)
|
||||
result = file_cmd.read_config(file_name=info_object["name"])
|
||||
if result["status"] is True:
|
||||
self._menu_controller.show_message("Profile loaded!")
|
||||
@@ -211,7 +211,7 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
# noinspection PyUnusedLocal
|
||||
def handle_action_menu_shutdown(self, info_object):
|
||||
"""Method handles the rotary button press on 'Shutdown' in the action menu."""
|
||||
self.ractl_cmd.shutdown("system")
|
||||
self.piscsi_cmd.shutdown("system")
|
||||
self._menu_controller.show_message("Shutting down!", 150)
|
||||
self._menu_controller.segue(
|
||||
CtrlBoardMenuBuilder.SCSI_ID_MENU,
|
||||
@@ -248,7 +248,7 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
context_object = self._menu_controller.get_active_menu().context_object
|
||||
scsi_id = context_object["scsi_id"]
|
||||
params = {"file": image_name}
|
||||
result = self.ractl_cmd.attach_device(
|
||||
result = self.piscsi_cmd.attach_device(
|
||||
scsi_id=scsi_id, device_type=device_type, params=params
|
||||
)
|
||||
|
||||
@@ -261,7 +261,7 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
"""Helper method to detach/eject an image on a scsi id given through the menu context"""
|
||||
context_object = self._menu_controller.get_active_menu().context_object
|
||||
scsi_id = context_object["scsi_id"]
|
||||
device_info = self.ractl_cmd.list_devices(scsi_id)
|
||||
device_info = self.piscsi_cmd.list_devices(scsi_id)
|
||||
|
||||
if not device_info["device_list"]:
|
||||
return
|
||||
@@ -269,20 +269,20 @@ class CtrlBoardMenuUpdateEventHandler(Observer):
|
||||
device_type = device_info["device_list"][0]["device_type"]
|
||||
image = device_info["device_list"][0]["image"]
|
||||
if device_type in ("SCHD", "SCBR", "SCDP", "SCLP", "SCHS"):
|
||||
result = self.ractl_cmd.detach_by_id(scsi_id)
|
||||
result = self.piscsi_cmd.detach_by_id(scsi_id)
|
||||
if result["status"] is True:
|
||||
self.show_id_action_message(scsi_id, "detached")
|
||||
else:
|
||||
self._menu_controller.show_message("Detach failed!")
|
||||
elif device_type in ("SCRM", "SCMO", "SCCD"):
|
||||
if image:
|
||||
result = self.ractl_cmd.eject_by_id(scsi_id)
|
||||
result = self.piscsi_cmd.eject_by_id(scsi_id)
|
||||
if result["status"] is True:
|
||||
self.show_id_action_message(scsi_id, "ejected")
|
||||
else:
|
||||
self._menu_controller.show_message("Eject failed!")
|
||||
else:
|
||||
result = self.ractl_cmd.detach_by_id(scsi_id)
|
||||
result = self.piscsi_cmd.detach_by_id(scsi_id)
|
||||
if result["status"] is True:
|
||||
self.show_id_action_message(scsi_id, "detached")
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Module for test printing events when buttons from the RaSCSI Control Board are pressed"""
|
||||
"""Module for test printing events when buttons from the PiSCSI Control Board are pressed"""
|
||||
import observer
|
||||
from ctrlboard_hw.hardware_button import HardwareButton
|
||||
from ctrlboard_hw.encoder import Encoder
|
||||
@@ -6,7 +6,7 @@ from ctrlboard_hw.encoder import Encoder
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class CtrlBoardPrintEventHandler(observer.Observer):
|
||||
"""Class implements a basic event handler that prints button presses from the RaSCSI
|
||||
"""Class implements a basic event handler that prints button presses from the PiSCSI
|
||||
Control Board hardware."""
|
||||
|
||||
def update(self, updated_object):
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
"""Module providing the profile cycler class for the RaSCSI Control Board UI"""
|
||||
"""Module providing the profile cycler class for the PiSCSI Control Board UI"""
|
||||
from ctrlboard_menu_builder import CtrlBoardMenuBuilder
|
||||
from menu.cycler import Cycler
|
||||
|
||||
|
||||
class RascsiProfileCycler(Cycler):
|
||||
"""Class implementing the profile cycler for the RaSCSI Control Baord UI"""
|
||||
class PiscsiProfileCycler(Cycler):
|
||||
"""Class implementing the profile cycler for the PiSCSI Control Baord UI"""
|
||||
|
||||
def populate_cycle_entries(self):
|
||||
cycle_entries = self.file_cmd.list_config_files()
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
"""Module providing the shutdown cycler for the RaSCSI Control Board UI """
|
||||
"""Module providing the shutdown cycler for the PiSCSI Control Board UI """
|
||||
from menu.cycler import Cycler
|
||||
|
||||
|
||||
class RascsiShutdownCycler(Cycler):
|
||||
"""Class implementing the shutdown cycler for the RaSCSI Control Board UI"""
|
||||
class PiscsiShutdownCycler(Cycler):
|
||||
"""Class implementing the shutdown cycler for the PiSCSI Control Board UI"""
|
||||
|
||||
def __init__(self, menu_controller, sock_cmd, ractl_cmd):
|
||||
def __init__(self, menu_controller, sock_cmd, piscsi_cmd):
|
||||
super().__init__(
|
||||
menu_controller,
|
||||
sock_cmd,
|
||||
ractl_cmd,
|
||||
piscsi_cmd,
|
||||
return_entry=True,
|
||||
empty_messages=False,
|
||||
)
|
||||
@@ -24,7 +24,7 @@ class RascsiShutdownCycler(Cycler):
|
||||
if self.executed_once is False:
|
||||
self.executed_once = True
|
||||
self._menu_controller.show_timed_message("Shutting down...")
|
||||
self.ractl_cmd.shutdown("system")
|
||||
self.piscsi_cmd.shutdown("system")
|
||||
return "shutdown"
|
||||
|
||||
return None
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Module providing the interface to the RaSCSI Control Board hardware"""
|
||||
"""Module providing the interface to the PiSCSI Control Board hardware"""
|
||||
# noinspection PyUnresolvedReferences
|
||||
import logging
|
||||
import time
|
||||
@@ -15,19 +15,19 @@ from observable import Observable
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class CtrlBoardHardware(Observable):
|
||||
"""Class implements the RaSCSI Control Board hardware and provides an interface to it."""
|
||||
"""Class implements the PiSCSI Control Board hardware and provides an interface to it."""
|
||||
|
||||
def __init__(self, display_i2c_address, pca9554_i2c_address, debounce_ms=200):
|
||||
self.display_i2c_address = display_i2c_address
|
||||
self.pca9554_i2c_address = pca9554_i2c_address
|
||||
self.debounce_ms = debounce_ms
|
||||
self.rascsi_controlboard_detected = self.detect_rascsi_controlboard()
|
||||
self.piscsi_controlboard_detected = self.detect_piscsi_controlboard()
|
||||
log = logging.getLogger(__name__)
|
||||
log.info("RaSCSI Control Board detected: %s", str(self.rascsi_controlboard_detected))
|
||||
log.info("PiSCSI Control Board detected: %s", str(self.piscsi_controlboard_detected))
|
||||
self.display_detected = self.detect_display()
|
||||
log.info("Display detected: %s", str(self.display_detected))
|
||||
|
||||
if self.rascsi_controlboard_detected is False:
|
||||
if self.piscsi_controlboard_detected is False:
|
||||
return
|
||||
|
||||
self.pos = 0
|
||||
@@ -234,8 +234,8 @@ class CtrlBoardHardware(Observable):
|
||||
|
||||
return detected_i2c_addresses
|
||||
|
||||
def detect_rascsi_controlboard(self):
|
||||
"""Detects whether the RaSCSI Control Board is attached by checking whether
|
||||
def detect_piscsi_controlboard(self):
|
||||
"""Detects whether the PiSCSI Control Board is attached by checking whether
|
||||
the expected i2c addresses are detected."""
|
||||
# pylint: disable=c-extension-no-member
|
||||
i2c_addresses = self.detect_i2c_devices(smbus.SMBus(1))
|
||||
@@ -247,7 +247,7 @@ class CtrlBoardHardware(Observable):
|
||||
)
|
||||
|
||||
def detect_display(self):
|
||||
"""Detects whether an i2c display is connected to the RaSCSI hat."""
|
||||
"""Detects whether an i2c display is connected to the PiSCSI hat."""
|
||||
# pylint: disable=c-extension-no-member
|
||||
i2c_addresses = self.detect_i2c_devices(smbus.SMBus(1))
|
||||
return bool(int(self.display_i2c_address) in i2c_addresses)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Module containing the RaSCSI Control Board hardware constants"""
|
||||
"""Module containing the PiSCSI Control Board hardware constants"""
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class CtrlBoardHardwareConstants:
|
||||
"""Class containing the RaSCSI Control Board hardware constants"""
|
||||
"""Class containing the PiSCSI Control Board hardware constants"""
|
||||
|
||||
DISPLAY_I2C_ADDRESS = 0x3C
|
||||
PCA9554_I2C_ADDRESS = 0x3F
|
||||
|
||||
@@ -3,8 +3,8 @@ import logging
|
||||
|
||||
from menu.menu import Menu
|
||||
from menu.menu_builder import MenuBuilder
|
||||
from rascsi.file_cmds import FileCmds
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
from piscsi.file_cmds import FileCmds
|
||||
from piscsi.piscsi_cmds import PiscsiCmds
|
||||
|
||||
|
||||
class CtrlBoardMenuBuilder(MenuBuilder):
|
||||
@@ -25,14 +25,14 @@ class CtrlBoardMenuBuilder(MenuBuilder):
|
||||
ACTION_LOADPROFILE = "loadprofile"
|
||||
ACTION_IMAGE_ATTACHINSERT = "image_attachinsert"
|
||||
|
||||
def __init__(self, ractl_cmd: RaCtlCmds):
|
||||
def __init__(self, piscsi_cmd: PiscsiCmds):
|
||||
super().__init__()
|
||||
self._rascsi_client = ractl_cmd
|
||||
self._piscsi_client = piscsi_cmd
|
||||
self.file_cmd = FileCmds(
|
||||
sock_cmd=ractl_cmd.sock_cmd,
|
||||
ractl=ractl_cmd,
|
||||
token=ractl_cmd.token,
|
||||
locale=ractl_cmd.locale,
|
||||
sock_cmd=piscsi_cmd.sock_cmd,
|
||||
piscsi=piscsi_cmd,
|
||||
token=piscsi_cmd.token,
|
||||
locale=piscsi_cmd.locale,
|
||||
)
|
||||
|
||||
def build(self, name: str, context_object=None) -> Menu:
|
||||
@@ -55,8 +55,8 @@ class CtrlBoardMenuBuilder(MenuBuilder):
|
||||
# pylint: disable=unused-argument
|
||||
def create_scsi_id_list_menu(self, context_object=None):
|
||||
"""Method creates the menu displaying the 7 scsi slots"""
|
||||
devices = self._rascsi_client.list_devices()
|
||||
reserved_ids = self._rascsi_client.get_reserved_ids()
|
||||
devices = self._piscsi_client.list_devices()
|
||||
reserved_ids = self._piscsi_client.get_reserved_ids()
|
||||
|
||||
devices_by_id = {}
|
||||
for device in devices["device_list"]:
|
||||
@@ -179,7 +179,7 @@ class CtrlBoardMenuBuilder(MenuBuilder):
|
||||
menu = Menu(CtrlBoardMenuBuilder.DEVICEINFO_MENU)
|
||||
menu.add_entry("Return", {"context": self.DEVICEINFO_MENU, "action": self.ACTION_RETURN})
|
||||
|
||||
device_info = self._rascsi_client.list_devices(context_object["scsi_id"])
|
||||
device_info = self._piscsi_client.list_devices(context_object["scsi_id"])
|
||||
|
||||
if not device_info["device_list"]:
|
||||
return menu
|
||||
@@ -210,6 +210,6 @@ class CtrlBoardMenuBuilder(MenuBuilder):
|
||||
|
||||
return menu
|
||||
|
||||
def get_rascsi_client(self):
|
||||
"""Returns an instance of the rascsi client"""
|
||||
return self._rascsi_client
|
||||
def get_piscsi_client(self):
|
||||
"""Returns an instance of the piscsi client"""
|
||||
return self._piscsi_client
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Module is the entry point for the RaSCSI Control Board UI"""
|
||||
"""Module is the entry point for the PiSCSI Control Board UI"""
|
||||
import argparse
|
||||
import sys
|
||||
import logging
|
||||
@@ -12,21 +12,21 @@ from ctrlboard_event_handler.ctrlboard_menu_update_event_handler import (
|
||||
from ctrlboard_menu_builder import CtrlBoardMenuBuilder
|
||||
from menu.menu_renderer_config import MenuRendererConfig
|
||||
from menu.menu_renderer_luma_oled import MenuRendererLumaOled
|
||||
from rascsi.exceptions import (
|
||||
from piscsi.exceptions import (
|
||||
EmptySocketChunkException,
|
||||
InvalidProtobufResponse,
|
||||
FailedSocketConnectionException,
|
||||
)
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
from rascsi.socket_cmds import SocketCmds
|
||||
from piscsi.piscsi_cmds import PiscsiCmds
|
||||
from piscsi.socket_cmds import SocketCmds
|
||||
|
||||
from rascsi_menu_controller import RascsiMenuController
|
||||
from piscsi_menu_controller import PiscsiMenuController
|
||||
|
||||
|
||||
def parse_config():
|
||||
"""Parses the command line parameters and configured the RaSCSI Control Board UI accordingly"""
|
||||
"""Parses the command line parameters and configured the PiSCSI Control Board UI accordingly"""
|
||||
config = CtrlboardConfig()
|
||||
cmdline_args_parser = argparse.ArgumentParser(description="RaSCSI ctrlboard service")
|
||||
cmdline_args_parser = argparse.ArgumentParser(description="PiSCSI ctrlboard service")
|
||||
cmdline_args_parser.add_argument(
|
||||
"--rotation",
|
||||
type=int,
|
||||
@@ -44,25 +44,25 @@ def parse_config():
|
||||
help="The pixel height of the screen buffer. Default: 64",
|
||||
)
|
||||
cmdline_args_parser.add_argument(
|
||||
"--rascsi-host",
|
||||
"--piscsi-host",
|
||||
type=str,
|
||||
default="localhost",
|
||||
action="store",
|
||||
help="RaSCSI host. Default: localhost",
|
||||
help="PiSCSI host. Default: localhost",
|
||||
)
|
||||
cmdline_args_parser.add_argument(
|
||||
"--rascsi-port",
|
||||
"--piscsi-port",
|
||||
type=int,
|
||||
default=6868,
|
||||
action="store",
|
||||
help="RaSCSI port. Default: 6868",
|
||||
help="PiSCSI port. Default: 6868",
|
||||
)
|
||||
cmdline_args_parser.add_argument(
|
||||
"--password",
|
||||
type=str,
|
||||
default="",
|
||||
action="store",
|
||||
help="Token password string for authenticating with RaSCSI",
|
||||
help="Token password string for authenticating with PiSCSI",
|
||||
)
|
||||
cmdline_args_parser.add_argument(
|
||||
"--loglevel",
|
||||
@@ -93,19 +93,19 @@ def parse_config():
|
||||
config.TOKEN = args.password
|
||||
config.WIDTH = 128
|
||||
config.BORDER = 5
|
||||
config.RASCSI_HOST = args.rascsi_host
|
||||
config.RASCSI_PORT = args.rascsi_port
|
||||
config.PISCSI_HOST = args.piscsi_host
|
||||
config.PISCSI_PORT = args.piscsi_port
|
||||
config.LOG_LEVEL = args.loglevel
|
||||
config.TRANSITIONS = bool(args.transitions)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def check_rascsi_connection(ractl_cmd):
|
||||
"""Checks whether a RaSCSI connection exists by polling the RaSCSI server info.
|
||||
def check_piscsi_connection(piscsi_cmd):
|
||||
"""Checks whether a PiSCSI connection exists by polling the PiSCSI server info.
|
||||
Returns true if connection works, false if connection fails."""
|
||||
try:
|
||||
info = ractl_cmd.get_reserved_ids()
|
||||
info = piscsi_cmd.get_reserved_ids()
|
||||
return bool(info["status"] is True)
|
||||
except FailedSocketConnectionException:
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -114,40 +114,40 @@ def check_rascsi_connection(ractl_cmd):
|
||||
|
||||
|
||||
def main():
|
||||
"""Main function for the RaSCSI Control Board UI"""
|
||||
"""Main function for the PiSCSI Control Board UI"""
|
||||
config = parse_config()
|
||||
|
||||
log_format = "%(asctime)s:%(name)s:%(levelname)s - %(message)s"
|
||||
logging.basicConfig(stream=sys.stdout, format=log_format, level=config.LOG_LEVEL)
|
||||
log = logging.getLogger(__name__)
|
||||
log.debug("RaSCSI ctrlboard service started.")
|
||||
log.debug("PiSCSI ctrlboard service started.")
|
||||
|
||||
ctrlboard_hw = CtrlBoardHardware(
|
||||
display_i2c_address=config.DISPLAY_I2C_ADDRESS,
|
||||
pca9554_i2c_address=config.PCA9554_I2C_ADDRESS,
|
||||
)
|
||||
|
||||
# for now, we require the complete rascsi ctrlboard hardware.
|
||||
# for now, we require the complete piscsi ctrlboard hardware.
|
||||
# Oled only will be supported as well at some later point in time.
|
||||
if ctrlboard_hw.rascsi_controlboard_detected is False:
|
||||
if ctrlboard_hw.piscsi_controlboard_detected is False:
|
||||
log.error("Ctrlboard hardware not detected. Stopping service")
|
||||
exit(1)
|
||||
|
||||
sock_cmd = None
|
||||
ractl_cmd = None
|
||||
piscsi_cmd = None
|
||||
try:
|
||||
sock_cmd = SocketCmds(host=config.RASCSI_HOST, port=config.RASCSI_PORT)
|
||||
ractl_cmd = RaCtlCmds(sock_cmd=sock_cmd, token=config.TOKEN)
|
||||
sock_cmd = SocketCmds(host=config.PISCSI_HOST, port=config.PISCSI_PORT)
|
||||
piscsi_cmd = PiscsiCmds(sock_cmd=sock_cmd, token=config.TOKEN)
|
||||
except EmptySocketChunkException:
|
||||
log.error("Retrieved empty data from RaSCSI. Stopping service")
|
||||
log.error("Retrieved empty data from PiSCSI. Stopping service")
|
||||
exit(1)
|
||||
except InvalidProtobufResponse:
|
||||
log.error("Retrieved unexpected data from RaSCSI. Stopping service")
|
||||
log.error("Retrieved unexpected data from PiSCSI. Stopping service")
|
||||
exit(1)
|
||||
|
||||
if check_rascsi_connection(ractl_cmd) is False:
|
||||
if check_piscsi_connection(piscsi_cmd) is False:
|
||||
log.error(
|
||||
"Communication with RaSCSI failed. Please check if password token must be set "
|
||||
"Communication with PiSCSI failed. Please check if password token must be set "
|
||||
"and whether is set correctly."
|
||||
)
|
||||
exit(1)
|
||||
@@ -160,8 +160,8 @@ def main():
|
||||
menu_renderer_config.i2c_address = CtrlBoardHardwareConstants.DISPLAY_I2C_ADDRESS
|
||||
menu_renderer_config.rotation = config.ROTATION
|
||||
|
||||
menu_builder = CtrlBoardMenuBuilder(ractl_cmd)
|
||||
menu_controller = RascsiMenuController(
|
||||
menu_builder = CtrlBoardMenuBuilder(piscsi_cmd)
|
||||
menu_controller = PiscsiMenuController(
|
||||
config.MENU_REFRESH_INTERVAL,
|
||||
menu_builder=menu_builder,
|
||||
menu_renderer=MenuRendererLumaOled(menu_renderer_config),
|
||||
@@ -174,7 +174,7 @@ def main():
|
||||
menu_controller.show_splash_screen("resources/splash_start_64.bmp")
|
||||
|
||||
menu_update_event_handler = CtrlBoardMenuUpdateEventHandler(
|
||||
menu_controller, sock_cmd=sock_cmd, ractl_cmd=ractl_cmd
|
||||
menu_controller, sock_cmd=sock_cmd, piscsi_cmd=piscsi_cmd
|
||||
)
|
||||
ctrlboard_hw.attach(menu_update_event_handler)
|
||||
menu_controller.set_active_menu(CtrlBoardMenuBuilder.SCSI_ID_MENU)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Module that implements a button cycling functionality"""
|
||||
from abc import abstractmethod
|
||||
from menu.timer import Timer
|
||||
from rascsi.file_cmds import FileCmds
|
||||
from piscsi.file_cmds import FileCmds
|
||||
|
||||
|
||||
class Cycler:
|
||||
@@ -13,7 +13,7 @@ class Cycler:
|
||||
self,
|
||||
menu_controller,
|
||||
sock_cmd,
|
||||
ractl_cmd,
|
||||
piscsi_cmd,
|
||||
cycle_timeout=3,
|
||||
return_string="Return ->",
|
||||
return_entry=True,
|
||||
@@ -22,8 +22,8 @@ class Cycler:
|
||||
self._cycle_profile_timer_flag = Timer(activation_delay=cycle_timeout)
|
||||
self._menu_controller = menu_controller
|
||||
self.sock_cmd = sock_cmd
|
||||
self.ractl_cmd = ractl_cmd
|
||||
self.file_cmd = FileCmds(sock_cmd=self.sock_cmd, ractl=self.ractl_cmd)
|
||||
self.piscsi_cmd = piscsi_cmd
|
||||
self.file_cmd = FileCmds(sock_cmd=self.sock_cmd, piscsi=self.piscsi_cmd)
|
||||
self.cycle_entries = self.populate_cycle_entries()
|
||||
self.return_string = return_string
|
||||
self.return_entry = return_entry
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
"""Module implementing the RaSCSI Control Board UI specific menu controller"""
|
||||
"""Module implementing the PiSCSI Control Board UI specific menu controller"""
|
||||
from ctrlboard_menu_builder import CtrlBoardMenuBuilder
|
||||
from menu.menu_builder import MenuBuilder
|
||||
from menu.menu_controller import MenuController
|
||||
@@ -6,8 +6,8 @@ from menu.menu_renderer import MenuRenderer
|
||||
from menu.timer import Timer
|
||||
|
||||
|
||||
class RascsiMenuController(MenuController):
|
||||
"""Class implementing a RaSCSI Control Board UI specific menu controller"""
|
||||
class PiscsiMenuController(MenuController):
|
||||
"""Class implementing a PiSCSI Control Board UI specific menu controller"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -50,7 +50,7 @@ if [ $ERROR = 1 ] ; then
|
||||
fi
|
||||
|
||||
if pgrep -f "python3 src/main.py" &> /dev/null; then
|
||||
echo "Detected active rascsi control board service"
|
||||
echo "Detected active piscsi control board service"
|
||||
echo "Terminating before launching a new one."
|
||||
sudo pkill -f "python3 src/main.py"
|
||||
fi
|
||||
@@ -79,7 +79,7 @@ fi
|
||||
|
||||
# Create the venv if it doesn't exist
|
||||
if ! test -e venv; then
|
||||
echo "Creating python venv for RaSCSI control board service"
|
||||
echo "Creating python venv for PiSCSI control board service"
|
||||
python3 -m venv venv --system-site-packages
|
||||
echo "Activating venv"
|
||||
source venv/bin/activate
|
||||
@@ -115,7 +115,7 @@ set -e
|
||||
|
||||
export PYTHONPATH=${PWD}/src:${PWD}/../common/src
|
||||
|
||||
echo "Starting RaSCSI control board service..."
|
||||
echo "Starting PiSCSI control board service..."
|
||||
|
||||
if [[ ${PI_MODEL} =~ "Raspberry Pi 4" ]] || [[ ${PI_MODEL} =~ "Raspberry Pi 3" ]] ||
|
||||
[[ ${PI_MODEL} =~ "Raspberry Pi Zero 2" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user