mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
increase firmware flashing packet size
This commit is contained in:
committed by
David Lechner
parent
c3037a56e6
commit
0944a27eb9
@@ -63,8 +63,19 @@ export enum Result {
|
||||
|
||||
/**
|
||||
* The largest allowable size for the payload of the ProgramFlash command.
|
||||
*
|
||||
* Theoretically, this is MTU - 9. However, City hub and Control+ hub report
|
||||
* MTU of 158 but don't seem to be able to handle receiving that much data.
|
||||
* Anything larger than 32 causes the bootloader to lock up.
|
||||
*/
|
||||
export const MaxProgramFlashSize = 14;
|
||||
export const MaxProgramFlashSize: ReadonlyMap<HubType, number> = new Map<
|
||||
HubType,
|
||||
number
|
||||
>([
|
||||
[HubType.MoveHub, 14],
|
||||
[HubType.CityHub, 32],
|
||||
[HubType.CPlusHub, 32],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Flash memory protection level.
|
||||
@@ -111,7 +122,6 @@ export function createProgramFlashRequest(
|
||||
payload: ArrayBuffer,
|
||||
): Uint8Array {
|
||||
const size = payload.byteLength;
|
||||
assert(size <= MaxProgramFlashSize, 'payload is bigger than MaxProgramFlashSize');
|
||||
const msg = new Uint8Array(size + 6);
|
||||
const view = new DataView(msg.buffer);
|
||||
view.setUint8(0, Command.ProgramFlash);
|
||||
|
||||
Reference in New Issue
Block a user