Skip to content

pslab flash is broken since the SerialHandler refactor #292

Description

@thisisanubhav

pslab flash <hexfile> fails before it can talk to the bootloader. The refactor in e70d01d ("Refactor SerialHandler") moved ScienceLab to wrap a connection handler (ScienceLab(device), psl.device) and dropped the interface attribute. The flashing code still uses the old API:

  1. cli.main calls pslab.ScienceLab(args.port), passing the port string as the device:
    AttributeError: 'str' object has no attribute 'get_firmware_version'. With no -p, it autoconnects a second time, although main has already opened the port with SerialHandler.
  2. cli.flash reads psl.interface.baudrate:
    AttributeError: 'ScienceLab' object has no attribute 'interface'
  3. ScienceLab.enter_bootloader sets self.device.interface.baudrate:
    AttributeError: 'SerialHandler' object has no attribute 'interface'

flash also passes the ScienceLab itself to mcbootflash, which needs an object with read/write (psl.device has them; ScienceLab doesn't).

Reproduced with a SerialHandler on pyserial's loop:// port:

h = SerialHandler("loop://"); h._ser = serial.serial_for_url("loop://", baudrate=1000000)
psl = ScienceLab.__new__(ScienceLab); psl.device = h
cli.flash(psl, "fw.hex")   # AttributeError: 'ScienceLab' object has no attribute 'interface'
psl.enter_bootloader()      # AttributeError: 'SerialHandler' object has no attribute 'interface'

ScienceLab.read_log has the same leftover (self.device.interface.readline(), self.get_ack()). I haven't included it here, since it's not on the flashing path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions