Skip to content

Commit

Permalink
fix:const read length asign for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamsk98 committed Nov 12, 2024
1 parent 30e8956 commit 76a2279
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/flasherV2/loader_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
OLEDPOS,
} from "./protocol_handler";
export class MSPLoaderV2 extends SerialTransport {
DEFAULT_TIMEOUT = 2000;
conn_established = false;
FLASH_START_ADDRESS = 0x0000;
FLASH_MAX_BUFFER_SIZE = 0x0000;
Expand Down Expand Up @@ -77,7 +78,7 @@ export class MSPLoaderV2 extends SerialTransport {
}
async enableBSL() {
await this.send(new Uint8Array(this.sa2a(this.ESP_CMD.BSL_ENBL)));
await this.read(2000, 5);
await this.read(this.DEFAULT_TIMEOUT, 5);
await this.esp_oled_print("BSL", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
await this.sleep(100);
}
Expand Down Expand Up @@ -169,7 +170,7 @@ export class MSPLoaderV2 extends SerialTransport {
}
async mass_earse() {
if (!this.conn_established) await this.establish_conn();
await this.esp_oled_print("Erasing ...", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// await this.esp_oled_print("Erasing ...", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
this.debug("Mass Erasing ...");
let cmd: BSLCommand = { type: "MassErase" };
let send = await Protocol.getFrameRaw(cmd);
Expand All @@ -179,10 +180,10 @@ export class MSPLoaderV2 extends SerialTransport {
let res = Protocol.getResponse(resRaw, cmd);
if (res.response == BSLResponse.BSL_ACK) {
this.debug("Mass Erase Done");
this.esp_oled_print("Erase Done", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// this.esp_oled_print("Erase Done", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
} else {
this.debug("Mass Erase Failed", res.response);
this.esp_oled_print("Erase Failed", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// this.esp_oled_print("Erase Failed", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
}
}
async esp_oled_print(
Expand All @@ -192,8 +193,7 @@ export class MSPLoaderV2 extends SerialTransport {
y_offset = 0
) {
await this.send(new Uint8Array(this.sa2a(this.ESP_CMD.OLED_CLR)));
await this.receive();
// await this.send(new Uint8Array(this.sa2a(this.ESP_CMD.OLED_ON)));
await this.read(this.DEFAULT_TIMEOUT, 8);
let data = new Uint8Array([
...this.sa2a(this.ESP_CMD.OLED_PRINT),
align,
Expand All @@ -203,10 +203,11 @@ export class MSPLoaderV2 extends SerialTransport {
]);
await this.send(data);
await this.receive();
await this.read(this.DEFAULT_TIMEOUT, 5);
}
async program_data(hex: string) {
if (!this.conn_established) await this.establish_conn();
await this.esp_oled_print("Flashing...", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// await this.esp_oled_print("Flashing...", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
const raw = this.intelHexToUint8Array(hex);
let address = 0x00000000; //this.FLASH_START_ADDRESS;
console.log("adress", address);
Expand All @@ -221,7 +222,7 @@ export class MSPLoaderV2 extends SerialTransport {
let res = Protocol.getResponse(resRaw, cmd);
if (res.response == BSLResponse.BSL_ACK) {
this.debug("Data Programmed");
this.esp_oled_print("Flashed", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// this.esp_oled_print("Flashed", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
} else {
this.debug("Data Program Failed", res.response);
throw new Error("Data Program Failed");
Expand All @@ -242,7 +243,7 @@ export class MSPLoaderV2 extends SerialTransport {
let res = Protocol.getResponse(resRaw, cmd1);
if (res.response == BSLResponse.BSL_ACK) {
this.conn_established = false;
this.esp_oled_print("App Started", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
// this.esp_oled_print("App Started", OLEDPOS.ALIGN_TOP_LEFT, 0, 0);
this.debug("App Started");
} else {
this.debug("App Start Failed", res.response);
Expand Down
5 changes: 4 additions & 1 deletion src/flasherV2/transport_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ export class SerialTransport {
if (this.device.writable) {
const writer = this.device.writable.getWriter();
await writer.write(data);
this.debug("Data sent", data, true, false);
if (this.tracing) {
this.trace(`Write ${data.length} bytes: ${this.hexConvert(data)}`);
}
// this.debug("Data sent", data, true, false);
writer.releaseLock();
}
}
Expand Down

0 comments on commit 76a2279

Please sign in to comment.