Skip to content

Commit b983e58

Browse files
committed
增强兼容 K1
1 parent e60cddc commit b983e58

File tree

7 files changed

+62
-68
lines changed

7 files changed

+62
-68
lines changed

src/locale/en-US.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
'navbar.disconnect': 'Disconnect',
3131
'navbar.qa': 'Feedback',
3232
'global.8kb': '8KB (64Kbit)',
33+
'global.64kb': '64KB (512Kbit)',
3334
'global.128kb': '128KB (1Mbit)',
3435
'global.256kb': '256KB (2Mbit)',
3536
'global.384kb': '384KB (3Mbit)',
@@ -135,7 +136,7 @@ export default {
135136
'global.password': 'Password',
136137
'global.password2': 'Retype password ',
137138
'image.negative': 'Negative',
138-
'workplace.clickNotice': ' (Official firmware can only detect 8KB/64Kbit)',
139+
'workplace.clickNotice': ' (Official firmware can only detect 64KB/512Kbit)',
139140
'menu.cps.radio': 'Radio',
140141
'menu.cps.mdc': 'MDC Contact',
141142
'menu.cps.dtmf': 'DTMF Contact',

src/locale/zh-CN.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
'navbar.disconnect': '断开',
3131
'navbar.qa': '问题反馈',
3232
'global.8kb': '8KB(64Kbit)',
33+
'global.64kb': '64KB(512Kbit)',
3334
'global.128kb': '128KB(1Mbit)',
3435
'global.256kb': '256KB(2Mbit)',
3536
'global.384kb': '384KB(3Mbit)',
@@ -135,7 +136,7 @@ export default {
135136
'global.password': '*请输入密码',
136137
'global.password2': '*请再次输入密码',
137138
'image.negative': '反色',
138-
'workplace.clickNotice': '(官方固件只能检测 8KB/64Kbit)',
139+
'workplace.clickNotice': '(官方固件只能检测最大 64KB/512Kbit)',
139140
'menu.cps.radio': '收音机',
140141
'menu.cps.mdc': 'MDC 联系人',
141142
'menu.cps.dtmf': 'DTMF 联系人',

src/utils/serial.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,14 @@ async function check_eeprom(port, protocol = "official") {
12411241
eepromSize = 0x2000
12421242
}
12431243
await eeprom_write(port, 0, bk1, 0x08, protocol);
1244+
1245+
const bk2 = await eeprom_read(port, 0xFFF8, 0x08, protocol);
1246+
await eeprom_write(port, 0xFFF8, rawEEPROM, 0x08, protocol);
1247+
const check2 = await eeprom_read(port, 0xFFF8, 0x08, protocol);
1248+
if(rawEEPROM.toString() == check2.toString()){
1249+
eepromSize = 0x10000
1250+
}
1251+
await eeprom_write(port, 0xFFF8, bk2, 0x08, protocol);
12441252
}else{
12451253
const bk1 = await eeprom_read(port, 0, 0x08, protocol);
12461254
await eeprom_write(port, 0, rawEEPROM, 0x08, protocol);

src/views/dashboard/workplace/components/banner.vue

Lines changed: 21 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<script lang="ts" setup>
8484
import { reactive } from 'vue';
8585
import { useAppStore } from '@/store';
86-
import { eeprom_write, eeprom_reboot, eeprom_init, eeprom_read } from '@/utils/serial.js';
86+
import { eeprom_write, eeprom_reboot, eeprom_init, eeprom_read, check_eeprom } from '@/utils/serial.js';
8787
import { useI18n } from 'vue-i18n';
8888
const { t } = useI18n();
8989
@@ -103,69 +103,27 @@
103103
}
104104
105105
const checkEeprom = async () => {
106-
let eepromSize = t('workplace.unk');
107-
const random = [
108-
Math.round(Math.random() * 256),
109-
Math.round(Math.random() * 256),
110-
Math.round(Math.random() * 256),
111-
Math.round(Math.random() * 256),
112-
Math.round(Math.random() * 256),
113-
Math.round(Math.random() * 256),
114-
Math.round(Math.random() * 256),
115-
Math.round(Math.random() * 256)
116-
]
117-
await eeprom_init(appStore.connectPort);
118-
const rawEEPROM = new Uint8Array(random);
119-
if(appStore.configuration?.uart == 'official'){
120-
const bk1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
121-
await eeprom_write(appStore.connectPort, 0, rawEEPROM, 0x08, appStore.configuration?.uart);
122-
const check1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
123-
if(rawEEPROM.toString() == check1.toString()){
124-
eepromSize = t('global.8kb')
125-
}
126-
await eeprom_write(appStore.connectPort, 0, bk1, 0x08, appStore.configuration?.uart);
127-
}else{
128-
const bk1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
129-
await eeprom_write(appStore.connectPort, 0, rawEEPROM, 0x08, appStore.configuration?.uart);
130-
const check1 = await eeprom_read(appStore.connectPort, 0, 0x08, appStore.configuration?.uart);
131-
if(rawEEPROM.toString() == check1.toString()){
132-
eepromSize = t('global.8kb')
133-
}
134-
await eeprom_write(appStore.connectPort, 0, bk1, 0x08, appStore.configuration?.uart);
135-
136-
const bk2 = await eeprom_read(appStore.connectPort, 0x1FFF8, 0x08, appStore.configuration?.uart);
137-
await eeprom_write(appStore.connectPort, 0x1FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
138-
const check2 = await eeprom_read(appStore.connectPort, 0x1FFF8, 0x08, appStore.configuration?.uart);
139-
if(rawEEPROM.toString() == check2.toString()){
140-
eepromSize = t('global.128kb')
141-
}
142-
await eeprom_write(appStore.connectPort, 0x1FFF8, bk2, 0x08, appStore.configuration?.uart);
143-
144-
const bk3 = await eeprom_read(appStore.connectPort, 0x3FFF8, 0x08, appStore.configuration?.uart);
145-
await eeprom_write(appStore.connectPort, 0x3FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
146-
const check3 = await eeprom_read(appStore.connectPort, 0x3FFF8, 0x08, appStore.configuration?.uart);
147-
if(rawEEPROM.toString() == check3.toString()){
148-
eepromSize = t('global.256kb')
149-
}
150-
await eeprom_write(appStore.connectPort, 0x3FFF8, bk3, 0x08, appStore.configuration?.uart);
151-
152-
const bk5 = await eeprom_read(appStore.connectPort, 0x5FFF8, 0x08, appStore.configuration?.uart);
153-
await eeprom_write(appStore.connectPort, 0x5FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
154-
const check5 = await eeprom_read(appStore.connectPort, 0x5FFF8, 0x08, appStore.configuration?.uart);
155-
if(rawEEPROM.toString() == check5.toString()){
156-
eepromSize = t('global.384kb')
157-
}
158-
await eeprom_write(appStore.connectPort, 0x5FFF8, bk5, 0x08, appStore.configuration?.uart);
159-
160-
const bk4 = await eeprom_read(appStore.connectPort, 0x7FFF8, 0x08, appStore.configuration?.uart);
161-
await eeprom_write(appStore.connectPort, 0x7FFF8, rawEEPROM, 0x08, appStore.configuration?.uart);
162-
const check4 = await eeprom_read(appStore.connectPort, 0x7FFF8, 0x08, appStore.configuration?.uart);
163-
if(rawEEPROM.toString() == check4.toString()){
164-
eepromSize = t('global.512kb')
165-
}
166-
await eeprom_write(appStore.connectPort, 0x7FFF8, bk4, 0x08, appStore.configuration?.uart);
106+
const eepromSize = await check_eeprom(appStore.connectPort, appStore.configuration?.uart);
107+
switch(eepromSize){
108+
case 0x2000:
109+
state.eepromSize = t('global.8kb');
110+
break;
111+
case 0x10000:
112+
state.eepromSize = t('global.64kb');
113+
break;
114+
case 0x20000:
115+
state.eepromSize = t('global.128kb');
116+
break;
117+
case 0x40000:
118+
state.eepromSize = t('global.256kb');
119+
break;
120+
case 0x80000:
121+
state.eepromSize = t('global.512kb');
122+
break;
123+
default:
124+
state.eepromSize = t('workplace.unk');
125+
break;
167126
}
168-
state.eepromSize = eepromSize;
169127
}
170128
</script>
171129

src/views/list/card/index.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<a-button @click="restore">{{ $t('tool.restore') }}</a-button>
2424
<a-select v-model="state.eepromType" :style="{width:'320px'}" :placeholder="$t('tool.selectSize')">
2525
<a-option value="1">{{ $t('global.8kb') }}</a-option>
26+
<a-option value="5">{{ $t('global.64kb') }}</a-option>
2627
<a-option value="2">{{ $t('global.128kb') }}</a-option>
2728
<a-option value="3">{{ $t('global.256kb') }}</a-option>
2829
<a-option value="4">{{ $t('global.512kb') }}</a-option>
@@ -88,6 +89,9 @@ const checkEeprom = async () => {
8889
case 0x2000:
8990
state.eepromType = "1";
9091
break;
92+
case 0x10000:
93+
state.eepromType = "5";
94+
break;
9195
case 0x20000:
9296
state.eepromType = "2";
9397
break;
@@ -202,6 +206,9 @@ const backup = async() => {
202206
case "4":
203207
_max = 0x80000;
204208
break;
209+
case '5':
210+
_max = 0x10000;
211+
break;
205212
default:
206213
_max = 0x2000;
207214
}

src/views/list/image/index.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import { reactive, onMounted } from 'vue';
3434
import { useRoute } from 'vue-router';
3535
import { useAppStore } from '@/store';
36-
import { eeprom_write, eeprom_reboot, eeprom_init } from '@/utils/serial.js';
36+
import { eeprom_write, eeprom_reboot, eeprom_init, disconnect } from '@/utils/serial.js';
3737
3838
const appStore = useAppStore();
3939
@@ -203,7 +203,22 @@ const flashIt = async () => {
203203
state.binaryFile = outputArray;
204204
if(appStore.connectState != true){alert(sessionStorage.getItem('noticeConnectK5')); return;};
205205
if(appStore.configuration?.uart == "official"){
206-
alert(sessionStorage.getItem('noticeVersionNoSupport'));
206+
if(appStore.configuration?.charset != "gb2312"){
207+
alert(sessionStorage.getItem('noticeVersionNoSupport'));
208+
return;
209+
}
210+
state.loading = true
211+
let position = 0x3000;
212+
await eeprom_init(appStore.connectPort);
213+
let rawEEPROM = state.binaryFile;
214+
rawEEPROM = [0x5A, 0x5A, 0xBC, 0x9A, 0x00, 0x04, 0xFF, 0xFF, ...rawEEPROM];
215+
for (let i = position; i < rawEEPROM.length + position; i += 0x40) {
216+
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i - position, i - position + 0x40), rawEEPROM.slice(i - position, i - position + 0x40).length, appStore.configuration?.uart);
217+
}
218+
await eeprom_reboot(appStore.connectPort);
219+
state.loading = false
220+
await disconnect(appStore.connectPort);
221+
appStore.updateSettings({ connectState: false, connectPort: null, firmwareVersion: "" });
207222
return;
208223
}
209224
if(appStore.configuration?.charset != "losehu" && appStore.configuration?.charset != "gb2312"){

src/views/list/search-table/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
import { useRoute } from 'vue-router';
116116
import { Input, Select } from 'tdesign-vue-next';
117117
import useLoading from '@/hooks/loading';
118-
import { eeprom_read, uint8ArrayToHexReverseString, uint8ArrayToString, hexReverseStringToUint8Array, stringToUint8Array, eeprom_write, eeprom_reboot, eeprom_init } from '@/utils/serial.js';
118+
import { eeprom_read, uint8ArrayToHexReverseString, uint8ArrayToString, hexReverseStringToUint8Array, stringToUint8Array, eeprom_write, eeprom_reboot, eeprom_init, disconnect } from '@/utils/serial.js';
119119
import { useAppStore } from '@/store';
120120
import { MoveIcon } from 'tdesign-icons-vue-next';
121121
import Chinese from 'chinese-s2t';
@@ -777,6 +777,10 @@
777777
await eeprom_reboot(appStore.connectPort);
778778
setLoading(false)
779779
progress.value = 0
780+
if(appStore.configuration?.uart == "official" && appStore.configuration?.charset == "gb2312"){
781+
await disconnect(appStore.connectPort);
782+
appStore.updateSettings({ connectState: false, connectPort: null, firmwareVersion: "" });
783+
}
780784
}
781785
const clearRow = async (row: any) =>{
782786
const newData = [...cstate.renderData];

0 commit comments

Comments
 (0)