This adds various tests, integrated into setuptools. These use "monkey
patching" where needed to mock the pyserial and packet reader/writer
functionality to allow for testing with no changes.
The code should be refactored to simplify testing, but this is good enough
to stop regressions for now.
It looks like it wasn't correct. The last value sent is probably
supposed to be the trim value for the chosen trim frequency.
Found while investigating grigorig/stcgal#16.
It's not needed on STC12 and up. All transfers are error checked with
parity and a 16-bit modular sum already. STC15 dropped the verification
checksum on the protocol level, it's not sent with the write status
packet, which is a testament to this not being needed.
Some parts store the UID in the last bytes of flash memory and this
verification actually caused incorrect verification failures because
of the verification, which apparently read the UID on verification
readback.
Fixesgrigorig/stcgal#15.
Don't ignore permission denied when looking for a suitable USB device.
Otherwise users don't notice what the problem is, stcgal will just
keep waiting on the prompt.
Completely revamp option handling. This fixes a wrong index of MCS4,
which is now renamed to MCS3. Now programming should be exactly
similar to STC-ISP 6.85M.
This also renames the values of the low_voltage_reset option for
clarity.
Also update the documentation and clarity the meaning of the option
according to protocol family.
Addresses grigorig/stcgal#14.
If a previous stcgal invocation is aborted, we can be in a bad state
upon connect. Add a simple sanity check based on packet length to
detect this and drop unsuitable packets.
The STC15W4 series have an additional USB BSL mode which kind of wraps
the serial protocol. It just uses basic USB control transfers. This
adds support for this mode, based on the existing STC15 code. pyusb is
required as an additional dependency. The new protocol mode is called
"usb15". There are some shortcomings, for instance timing of erase
and programming operations is problematic and right now only delays
are used. Also, only a single USB-ISP device is supported and the
first one found is always used.
Flash programming and setting options has been mildly tested on an
STC15W4K56S4 MCU.