mirror of
https://github.com/silenty4ng/k5web
synced 2025-01-08 04:44:29 +00:00
update
This commit is contained in:
parent
18897f3f39
commit
94f8ea3c66
1 changed files with 56 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { useAppStore } from '@/store';
|
||||
import { eeprom_write, eeprom_reboot, eeprom_init, eeprom_read } from '@/utils/serial.js';
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
|
@ -30,7 +31,61 @@
|
|||
})
|
||||
|
||||
const checkEeprom = async () => {
|
||||
alert('TODO');
|
||||
let eepromSize = '未知、故障、不可用';
|
||||
const random = [
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256),
|
||||
Math.round(Math.random() * 256)
|
||||
]
|
||||
await eeprom_init(appStore.connectPort);
|
||||
const rawEEPROM = new Uint8Array(random);
|
||||
if(appStore.configuration?.uart == 'official'){
|
||||
const bk1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
|
||||
await eeprom_write(appStore.connectPort, 0, rawEEPROM, 0x08, appStore.configuration?.uart);
|
||||
const check1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
|
||||
if(rawEEPROM.toString() == check1.toString()){
|
||||
eepromSize = '8KB(64Kbit)'
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0, bk1, 0x08, appStore.configuration?.uart);
|
||||
}else{
|
||||
const bk1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
|
||||
await eeprom_write(appStore.connectPort, 0, rawEEPROM, 0x08, appStore.configuration?.uart);
|
||||
const check1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
|
||||
if(rawEEPROM.toString() == check1.toString()){
|
||||
eepromSize = '8KB(64Kbit)'
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0, bk1, 0x08, appStore.configuration?.uart);
|
||||
|
||||
const bk2 = await eeprom_read(appStore.connectPort, 0x1FFF8, 0x08, appStore.configuration?.uart);
|
||||
await eeprom_write(appStore.connectPort, 0x1FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
|
||||
const check2 = await eeprom_read(appStore.connectPort, 0x1FFF8, 0x08, appStore.configuration?.uart);
|
||||
if(rawEEPROM.toString() == check2.toString()){
|
||||
eepromSize = '128KB(1Mbit)'
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0x1FFF8, bk2, 0x08, appStore.configuration?.uart);
|
||||
|
||||
const bk3 = await eeprom_read(appStore.connectPort, 0x3FFF8, 0x08, appStore.configuration?.uart);
|
||||
await eeprom_write(appStore.connectPort, 0x3FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
|
||||
const check3 = await eeprom_read(appStore.connectPort, 0x3FFF8, 0x08, appStore.configuration?.uart);
|
||||
if(rawEEPROM.toString() == check3.toString()){
|
||||
eepromSize = '256KB(2Mbit)'
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0x3FFF8, bk3, 0x08, appStore.configuration?.uart);
|
||||
|
||||
const bk4 = await eeprom_read(appStore.connectPort, 0x7FFF8, 0x08, appStore.configuration?.uart);
|
||||
await eeprom_write(appStore.connectPort, 0x7FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
|
||||
const check4 = await eeprom_read(appStore.connectPort, 0x7FFF8, 0x08, appStore.configuration?.uart);
|
||||
if(rawEEPROM.toString() == check4.toString()){
|
||||
eepromSize = '512KB(4Mbit)'
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0x7FFF8, bk4, 0x08, appStore.configuration?.uart);
|
||||
}
|
||||
state.eepromSize = eepromSize;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue