Skip to content

Commit

Permalink
Add self test command
Browse files Browse the repository at this point in the history
  • Loading branch information
squix78 committed Jun 10, 2024
1 parent df04c51 commit c0b4f70
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/components/testrunner/testrunner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export class TestrunnerComponent implements OnInit {
case TestState.Restarted:
console.log("Restarted");
this.stepper.selectedIndex = 2;
break;
case TestState.Testing:
console.log("Testing");
this.espPortService.sendSelfTestCommand();
break;

}
});
}
Expand Down
26 changes: 25 additions & 1 deletion src/app/shared/esp-port.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class EspPortService {

// Characters contained in the first messages after reboot in an ESP32
private resetMessageMatchers: string[] = ['rst:0x1', 'configsip', 'mode:DIO', 'entry 0x'];
private selfTestMatchers: string[] = ['READY_FOR_SELFTEST'];

private reader!: ReadableStreamDefaultReader;
private readableStreamClosed!: any;
Expand Down Expand Up @@ -116,7 +117,19 @@ export class EspPortService {
// and publish a message if that is the case
for (let matcher of this.resetMessageMatchers) {
if (message.indexOf(matcher) > -1) {
this.testStateSource.next(TestState.Restarted);
this.testStateSource.next(TestState.Restarted);
break;
}
}

}

checkForTesting(message: string) {
// Check the given console message for some trigger characters
// and publish a message if that is the case
for (let matcher of this.selfTestMatchers) {
if (message.indexOf(matcher) > -1) {
this.testStateSource.next(TestState.Testing);
break;
}
}
Expand All @@ -141,6 +154,16 @@ export class EspPortService {
this.testStateSource.next(isConnected ? TestState.Connected : TestState.Initial);
}

async sendSelfTestCommand() {
console.log("Sending self test command");
const encoder = new TextEncoder();
const writer = this.port.writable?.getWriter();
if (writer) {
await writer.write(encoder.encode("SELFTEST\n"));
writer.releaseLock();
}
}


async resetDevice() {
/*
Expand Down Expand Up @@ -198,6 +221,7 @@ export class EspPortService {
if (value && value !== "") {
console.log(value);
this.checkForRestart(value);
this.checkForTesting(value);
this.monitorMessageSource.next(value);
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/assets/defaultDeviceConfiguration.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,16 @@
"offset": 0,
"url": "./assets/espgateway/app-firmware.bin"
}]
},
{
"id": "pendrives3",
"name": "Pendrive S3",
"imageSource": "assets/pendrive-s3/pendrive-s3.jpg",
"partitions": [{
"name": "Firmware",
"data": [],
"offset": 0,
"url": "./assets/pendrive-s3/app-firmware.bin"
}]
}
]
Binary file added src/assets/pendrive-s3/app-firmware.bin
Binary file not shown.
Binary file added src/assets/pendrive-s3/pendrive-s3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c0b4f70

Please sign in to comment.