Exemplo n.º 1
0
 def __init__(self, printer, config):
     self._printer = printer
     self._config = config
     # Serial port
     baud = config.getint('baud', 250000)
     self._serialport = config.get('serial', '/dev/ttyS0')
     self.serial = serialhdl.SerialReader(printer.reactor, self._serialport,
                                          baud)
     self.is_shutdown = False
     self._shutdown_msg = ""
     self._is_fileoutput = False
     self._timeout_timer = printer.reactor.register_timer(
         self.timeout_handler)
     # Config building
     self._emergency_stop_cmd = self._clear_shutdown_cmd = None
     self._oids = []
     self._config_cmds = []
     self._config_crc = None
     self._init_callbacks = []
     self._pin_map = config.get('pin_map', None)
     self._custom = config.get('custom', '')
     # Move command queuing
     ffi_main, self.ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025)
     self._steppers = []
     self._steppersync = None
     # Print time to clock epoch calculations
     self._print_start_time = 0.
     self._mcu_freq = 0.
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
Exemplo n.º 2
0
 def __init__(self, config, clocksync):
     self._printer = config.get_printer()
     self._clocksync = clocksync
     self._reactor = self._printer.get_reactor()
     self._name = config.get_name()
     if self._name.startswith('mcu '):
         self._name = self._name[4:]
     self._printer.register_event_handler("klippy:connect", self._connect)
     self._printer.register_event_handler("klippy:mcu_identify",
                                          self._mcu_identify)
     self._printer.register_event_handler("klippy:shutdown", self._shutdown)
     self._printer.register_event_handler("klippy:disconnect",
                                          self._disconnect)
     # Serial port
     self._serialport = config.get('serial', '/dev/ttyS0')
     serial_rts = True
     if config.get('restart_method', None) == "cheetah":
         # Special case: Cheetah boards require RTS to be deasserted, else
         # a reset will trigger the built-in bootloader.
         serial_rts = False
     baud = 0
     if not (self._serialport.startswith("/dev/rpmsg_")
             or self._serialport.startswith("/tmp/klipper_host_")):
         baud = config.getint('baud', 250000, minval=2400)
     self._serial = serialhdl.SerialReader(self._reactor, self._serialport,
                                           baud, serial_rts)
     # Restarts
     self._restart_method = 'command'
     if baud:
         rmethods = {
             m: m
             for m in [None, 'arduino', 'cheetah', 'command', 'rpi_usb']
         }
         self._restart_method = config.getchoice('restart_method', rmethods,
                                                 None)
     self._reset_cmd = self._config_reset_cmd = None
     self._emergency_stop_cmd = None
     self._is_shutdown = self._is_timeout = False
     self._shutdown_msg = ""
     # Config building
     self._printer.lookup_object('pins').register_chip(self._name, self)
     self._oid_count = 0
     self._config_callbacks = []
     self._config_cmds = []
     self._restart_cmds = []
     self._init_cmds = []
     self._pin_map = config.get('pin_map', None)
     self._mcu_freq = 0.
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._stepqueues = []
     self._steppersync = None
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
     self._mcu_tick_awake = 0.
Exemplo n.º 3
0
 def __init__(self, reactor, serialport, baud, canbus_iface, canbus_nodeid):
     self.serialport = serialport
     self.baud = baud
     self.canbus_iface = canbus_iface
     self.canbus_nodeid = canbus_nodeid
     self.ser = serialhdl.SerialReader(reactor)
     self.reactor = reactor
     self.start_time = reactor.monotonic()
     self.clocksync = clocksync.ClockSync(self.reactor)
     self.fd = sys.stdin.fileno()
     util.set_nonblock(self.fd)
     self.mcu_freq = 0
     self.pins = pins.PinResolver(validate_aliases=False)
     self.data = ""
     reactor.register_fd(self.fd, self.process_kbd)
     reactor.register_callback(self.connect)
     self.local_commands = {
         "PINS": self.command_PINS,
         "SET": self.command_SET,
         "DELAY": self.command_DELAY,
         "FLOOD": self.command_FLOOD,
         "SUPPRESS": self.command_SUPPRESS,
         "STATS": self.command_STATS,
         "LIST": self.command_LIST,
         "HELP": self.command_HELP,
     }
     self.eval_globals = {}
Exemplo n.º 4
0
 def __init__(self, config, clocksync):
     self._printer = printer = config.get_printer()
     self._clocksync = clocksync
     self._reactor = printer.get_reactor()
     self._name = config.get_name()
     if self._name.startswith('mcu '):
         self._name = self._name[4:]
     # Serial port
     self._serialport = config.get('serial')
     self._baud = 0
     if not (self._serialport.startswith("/dev/rpmsg_")
             or self._serialport.startswith("/tmp/klipper_host_")):
         self._baud = config.getint('baud', 250000, minval=2400)
     self._serial = serialhdl.SerialReader(self._reactor)
     # Restarts
     restart_methods = [
         None, 'arduino', 'cheetah', 'command', 'rpi_usb', 'pin', 'script'
     ]
     self._restart_method = 'command'
     if self._baud:
         rmethods = {m: m for m in restart_methods}
         self._restart_method = config.getchoice('restart_method', rmethods,
                                                 None)
     self._reset_cmd = self._config_reset_cmd = None
     self._emergency_stop_cmd = None
     self._is_shutdown = self._is_timeout = False
     self._shutdown_msg = ""
     # Config building
     printer.lookup_object('pins').register_chip(self._name, self)
     self._oid_count = 0
     self._config_callbacks = []
     self._config_cmds = []
     self._restart_cmds = []
     self._init_cmds = []
     self._pin_map = config.get('pin_map', None)
     self._mcu_freq = 0.
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._reserved_move_slots = 0
     self._stepqueues = []
     self._steppersync = None
     # Stats
     self._get_status_info = {}
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
     self._mcu_tick_awake = 0.
     # Register handlers
     printer.register_event_handler("klippy:connect", self._connect)
     printer.register_event_handler("klippy:mcu_identify",
                                    self._mcu_identify)
     printer.register_event_handler("klippy:shutdown", self._shutdown)
     printer.register_event_handler("klippy:disconnect", self._disconnect)
Exemplo n.º 5
0
 def __init__(self, k_reactor, device, baud, board_cfg):
     self.reactor = k_reactor
     # TODO: a change in baudrate will cause an issue, come up
     # with a method for handling it gracefully
     self._serial = serialhdl.SerialReader(self.reactor, device, baud)
     self.clocksync = clocksync.ClockSync(self.reactor)
     self.board_config = board_cfg
     self.fatfs = None
     self.connect_completion = None
     self.connected = False
     self.enumerations = {}
Exemplo n.º 6
0
 def __init__(self, printer, config, clocksync):
     self._printer = printer
     self._clocksync = clocksync
     self._reactor = printer.get_reactor()
     self._name = config.get_name()
     if self._name.startswith('mcu '):
         self._name = self._name[4:]
     self.logger = printer.logger.getChild("mcu.%s" % (self._name, ))
     self._clocksync.setLogger(self.logger)
     # Serial port
     self._serialport = config.get('serial', '/dev/ttyS0')
     baud = config.getint('baud', 250000, minval=2400)
     if (self._serialport.startswith("/dev/rpmsg_")
             or self._serialport.startswith("/tmp/klipper_host_")):
         baud = 0
     self._serial = serialhdl.SerialReader(
         self._reactor,
         self._serialport,
         baud,
         logger=self.logger.getChild('serial'))
     # Restarts
     rmethods = {m: m for m in [None, 'arduino', 'command', 'rpi_usb']}
     self._restart_method = config.getchoice('restart_method', rmethods,
                                             None)
     if baud == 0:
         self._restart_method = 'command'
     self._reset_cmd = self._config_reset_cmd = None
     self._emergency_stop_cmd = None
     self._is_shutdown = self._is_timeout = False
     self._shutdown_msg = ""
     # Config building
     printer.lookup_object('pins').register_chip(self._name, self)
     self._oid_count = 0
     self._config_objects = []
     self._init_cmds = []
     self._config_cmds = []
     self._config_crc = None
     self._pin_map = config.get('pin_map', None)
     self._custom = config.get('custom', '')
     self._mcu_freq = 0.
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._stepqueues = []
     self._steppersync = None
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
     self._mcu_tick_awake = 0.
Exemplo n.º 7
0
def main():
    usage = "%prog [options] <serialdevice> <baud>"
    opts = optparse.OptionParser(usage)
    options, args = opts.parse_args()
    serialport, baud = args
    baud = int(baud)

    logging.basicConfig(level=logging.DEBUG)
    r = reactor.Reactor()
    ser = serialhdl.SerialReader(r, serialport, baud)
    kbd = KeyboardReader(ser, r)
    try:
        r.run()
    except KeyboardInterrupt:
        sys.stdout.write("\n")
Exemplo n.º 8
0
 def __init__(self, printer, config):
     self._printer = printer
     # Serial port
     self._serialport = config.get('serial', '/dev/ttyS0')
     if self._serialport.startswith("/dev/rpmsg_"):
         # Beaglbone PRU
         baud = 0
     else:
         baud = config.getint('baud', 250000, minval=2400)
     self.serial = serialhdl.SerialReader(printer.reactor, self._serialport,
                                          baud)
     self.is_shutdown = False
     self._shutdown_msg = ""
     self._timeout_timer = printer.reactor.register_timer(
         self.timeout_handler)
     self._restart_method = 'command'
     if baud:
         rmethods = {m: m for m in ['arduino', 'command', 'rpi_usb']}
         self._restart_method = config.getchoice('restart_method', rmethods,
                                                 'arduino')
     # Config building
     if printer.bglogger is not None:
         printer.bglogger.set_rollover_info("mcu", None)
     pins.get_printer_pins(printer).register_chip("mcu", self)
     self._emergency_stop_cmd = None
     self._reset_cmd = self._config_reset_cmd = None
     self._oid_count = 0
     self._config_objects = []
     self._init_cmds = []
     self._config_cmds = []
     self._config_crc = None
     self._pin_map = config.get('pin_map', None)
     self._custom = config.get('custom', '')
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._stepqueues = []
     self._steppersync = None
     # Print time to clock epoch calculations
     self._print_start_time = 0.
     self._mcu_freq = 0.
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
     self._mcu_tick_awake = 0.
Exemplo n.º 9
0
 def __init__(self, printer, config, clocksync):
     self._printer = printer
     self._clocksync = clocksync
     self._name = config.section
     if self._name.startswith('mcu '):
         self._name = self._name[4:]
     # Serial port
     self._serialport = config.get('serial', '/dev/ttyS0')
     baud = 0
     if not (self._serialport.startswith("/dev/rpmsg_")
             or self._serialport.startswith("/tmp/klipper_host_")):
         baud = config.getint('baud', 250000, minval=2400)
     self._serial = serialhdl.SerialReader(printer.reactor,
                                           self._serialport, baud)
     # Restarts
     self._restart_method = 'command'
     if baud:
         rmethods = {m: m for m in ['arduino', 'command', 'rpi_usb']}
         self._restart_method = config.getchoice('restart_method', rmethods,
                                                 'arduino')
     self._reset_cmd = self._config_reset_cmd = None
     self._emergency_stop_cmd = None
     self._is_shutdown = False
     self._shutdown_msg = ""
     if printer.bglogger is not None:
         printer.bglogger.set_rollover_info(self._name, None)
     # Config building
     pins.get_printer_pins(printer).register_chip(self._name, self)
     self._oid_count = 0
     self._config_objects = []
     self._init_cmds = []
     self._config_cmds = []
     self._config_crc = None
     self._pin_map = config.get('pin_map', None)
     self._custom = config.get('custom', '')
     self._mcu_freq = 0.
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._stepqueues = []
     self._steppersync = None
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.
     self._mcu_tick_awake = 0.
Exemplo n.º 10
0
 def __init__(self, printer, config):
     self._printer = printer
     # Serial port
     baud = config.getint('baud', 250000)
     self._serialport = config.get('serial', '/dev/ttyS0')
     self.serial = serialhdl.SerialReader(printer.reactor, self._serialport,
                                          baud)
     self.is_shutdown = False
     self._shutdown_msg = ""
     self._is_fileoutput = False
     self._timeout_timer = printer.reactor.register_timer(
         self.timeout_handler)
     rmethods = {m: m for m in ['arduino', 'command', 'rpi_usb']}
     self._restart_method = config.getchoice('restart_method', rmethods,
                                             'arduino')
     # Config building
     if printer.bglogger is not None:
         printer.bglogger.set_rollover_info("mcu", None)
     self._config_error = config.error
     self._emergency_stop_cmd = self._reset_cmd = None
     self._oids = []
     self._config_cmds = []
     self._config_crc = None
     self._init_callbacks = []
     self._pin_map = config.get('pin_map', None)
     self._custom = config.get('custom', '')
     # Move command queuing
     ffi_main, self._ffi_lib = chelper.get_ffi()
     self._max_stepper_error = config.getfloat('max_stepper_error',
                                               0.000025,
                                               minval=0.)
     self._steppers = []
     self._steppersync = None
     # Print time to clock epoch calculations
     self._print_start_time = 0.
     self._mcu_freq = 0.
     # Stats
     self._stats_sumsq_base = 0.
     self._mcu_tick_avg = 0.
     self._mcu_tick_stddev = 0.