Now that I've implemented the protocol, I see how commands actually give
return values isn't how I thought it would be. Accordingly,
_send_command now only returns the ReturnCode rather than wrapping it in
a list. This allowed me to remove a few [0]s.
As with the other commands that take a range of flash sectors, the end
is optional. I returns None if the sectors are blank, or an offset and
value if the sectors are not blank.
The new prepare_write method provides a Python interface to the P
command. If only one sector needs to be prepared, the end sector number
can be omitted.
Now the ISPError is raised from the _send_command method, not each
caller. There will be a few cases where I need that to not be an
exception, but I can just wrap it in a try block then, so there's no
problem.
Now instead of returning codes, the methods of LPC raise exceptions with
the information the chip returned.
The new read_memory method implements Python bindings for the R command.
The LPC class now has properties for getting and setting echo, baudrate,
and stopbits. Low-level access is now private to avoid letting users
break the public properties.
Also, a new write_ram method implements the W command. If no number of
bytes is specified, the length of the data is used.
Now we have code to connect to the serial port, put the LPC into ISP
mode, unlock the flash, and update echo and serial port settings. The
code's way nicer than lpc21isp so far, which is all I really wanted I
guess.