This commit is contained in:
Silent YANG 2024-02-25 14:21:11 +08:00
parent 18897f3f39
commit 94f8ea3c66

View file

@ -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 = '8KB64Kbit'
}
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 = '8KB64Kbit'
}
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 = '128KB1Mbit'
}
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 = '256KB2Mbit'
}
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 = '512KB4Mbit'
}
await eeprom_write(appStore.connectPort, 0x7FFF8, bk4, 0x08, appStore.configuration?.uart);
}
state.eepromSize = eepromSize;
}
</script>