fix: boundary scan could not save
This commit is contained in:
@@ -99,7 +99,6 @@ async function handleClick(event: Event): Promise<void> {
|
||||
isUploading.value = true;
|
||||
try {
|
||||
const ret = await props.uploadEvent(bitstream.value);
|
||||
console.debug(`After upload bistream: ${bitstream.value}, result: ${ret}`);
|
||||
if (isUndefined(props.downloadEvent)) {
|
||||
if (ret) {
|
||||
dialog.info("上传成功");
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-center text-2xl">Jtag</h1>
|
||||
<div class="flex flex-col">
|
||||
<p class="grow">Jtag Addr: {{ props.jtagAddr }}</p>
|
||||
<p class="grow">Jtag Port: {{ props.jtagPort?.toString() }}</p>
|
||||
<p class="grow">Jtag Addr: {{ eqps.boardAddr }}</p>
|
||||
<p class="grow">Jtag Port: {{ eqps.boardPort.toString() }}</p>
|
||||
<div class="flex justify-between grow">
|
||||
<p>IDCode: 0x{{ jtagIDCode.toString(16).padStart(8, "0") }}</p>
|
||||
<p>IDCode: 0x{{ jtagIDCode.toString(16).padStart(8, "0").toUpperCase() }}</p>
|
||||
<button class="btn btn-circle w-6 h-6" :onclick="getIDCode">
|
||||
<svg class="icon opacity-70 fill-primary" viewBox="0 0 1024 1024" version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg" p-id="4865" width="200" height="200">
|
||||
@@ -17,27 +17,30 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<UploadCard class="bg-base-200" :upload-event="uploadBitstream" :download-event="downloadBitstream"
|
||||
:bitstream-file="eqps.jtagBitstream" @update:bitstream-file="handleBitstreamChange">
|
||||
<UploadCard class="bg-base-200" :upload-event="eqps.jtagUploadBitstream"
|
||||
:download-event="eqps.jtagDownloadBitstream" :bitstream-file="eqps.jtagBitstream"
|
||||
@update:bitstream-file="handleBitstreamChange">
|
||||
</UploadCard>
|
||||
<div class="divider"></div>
|
||||
<button class="btn w-full btn-primary" :class="isEnableJtagBoundaryScan ? '' : 'btn-soft'"
|
||||
<fieldset class="fieldset w-full">
|
||||
<legend class="fieldset-legend text-sm">边界扫描刷新率 / Hz</legend>
|
||||
<input type="number" class="input validator w-full" required placeholder="Type a number between 1 to 1000" min="1"
|
||||
max="1000" v-model="jtagBoundaryScanFreq" title="Type a number between 1 to 1000" />
|
||||
<p class="validator-hint">输入一个1 ~ 1000的数</p>
|
||||
</fieldset>
|
||||
<button class="btn w-full btn-primary" :class="eqps.enableJtagBoundaryScan ? '' : 'btn-soft'"
|
||||
:onclick="toggleJtagBoundaryScan">
|
||||
{{ isEnableJtagBoundaryScan ? "关闭边界扫描" : "启动边界扫描" }}
|
||||
{{ eqps.enableJtagBoundaryScan ? "关闭边界扫描" : "启动边界扫描" }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { JtagClient } from "@/APIClient";
|
||||
import z from "zod";
|
||||
import UploadCard from "@/components/UploadCard.vue";
|
||||
import { useDialogStore } from "@/stores/dialog";
|
||||
import { Common } from "@/Common";
|
||||
import { useEquipments } from "@/stores/equipments";
|
||||
import { useConstraintsStore } from "@/stores/constraints";
|
||||
import { isUndefined } from "lodash";
|
||||
import { ref, watchEffect } from "vue";
|
||||
import { computed, ref, watchEffect } from "vue";
|
||||
|
||||
interface CapsProps {
|
||||
jtagAddr?: string;
|
||||
@@ -48,107 +51,38 @@ const props = withDefaults(defineProps<CapsProps>(), {});
|
||||
|
||||
// Global Stores
|
||||
const dialog = useDialogStore();
|
||||
const constrainsts = useConstraintsStore();
|
||||
const eqps = useEquipments();
|
||||
|
||||
const jtagController = new JtagClient();
|
||||
const isEnableJtagBoundaryScan = ref(false);
|
||||
const jtagBoundaryScanFreq = computed({
|
||||
get: () => eqps.jtagBoundaryScanFreq,
|
||||
set: (val) => {
|
||||
if (z.number().positive().max(1000).safeParse(val).success)
|
||||
eqps.jtagBoundaryScanFreq = val;
|
||||
},
|
||||
});
|
||||
|
||||
// 使用传入的属性或默认值
|
||||
const jtagIDCode = ref(0);
|
||||
const jtagIDCode = ref(0xffff_ffff);
|
||||
|
||||
function handleBitstreamChange(file: File | undefined) {
|
||||
eqps.jtagBitstream = file;
|
||||
}
|
||||
|
||||
async function toggleJtagBoundaryScan() {
|
||||
isEnableJtagBoundaryScan.value = !isEnableJtagBoundaryScan.value;
|
||||
if (isEnableJtagBoundaryScan.value) jtagBoundaryScan();
|
||||
}
|
||||
|
||||
async function jtagBoundaryScan() {
|
||||
try {
|
||||
const portStates = await jtagController.boundaryScanLogicalPorts(
|
||||
props.jtagAddr,
|
||||
props.jtagPort,
|
||||
);
|
||||
|
||||
constrainsts.batchSetConstraintStates(portStates);
|
||||
} catch (error) {
|
||||
dialog.error("边界扫描发生错误");
|
||||
console.error(error);
|
||||
isEnableJtagBoundaryScan.value = false;
|
||||
} finally {
|
||||
if (isEnableJtagBoundaryScan.value) setTimeout(jtagBoundaryScan, 50);
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadBitstream(bitstream: File): Promise<boolean> {
|
||||
if (isUndefined(props.jtagAddr) || isUndefined(props.jtagPort)) {
|
||||
dialog.error("开发板地址或端口空缺");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
console.debug(`Before upload bistream: ${bitstream}`);
|
||||
const resp = await jtagController.uploadBitstream(
|
||||
props.jtagAddr,
|
||||
Common.toFileParameterOrNull(bitstream),
|
||||
);
|
||||
return resp;
|
||||
} catch (e) {
|
||||
dialog.error("上传错误");
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadBitstream(): Promise<boolean> {
|
||||
if (isUndefined(props.jtagAddr) || isUndefined(props.jtagPort)) {
|
||||
dialog.error("开发板地址或端口空缺");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await jtagController.downloadBitstream(
|
||||
props.jtagAddr,
|
||||
props.jtagPort,
|
||||
);
|
||||
return resp;
|
||||
} catch (e) {
|
||||
dialog.error("上传错误");
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function getIDCode(isQuiet: boolean = false) {
|
||||
if (isUndefined(props.jtagAddr) || isUndefined(props.jtagPort)) {
|
||||
dialog.error("开发板地址或端口空缺");
|
||||
if (eqps.jtagClientMutex.isLocked()) {
|
||||
dialog.warn("Jtag正在被占用");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await jtagController.getDeviceIDCode(
|
||||
props.jtagAddr,
|
||||
props.jtagPort,
|
||||
);
|
||||
jtagIDCode.value = resp;
|
||||
} catch (e) {
|
||||
if (!isQuiet) dialog.error("获取IDCode错误");
|
||||
}
|
||||
eqps.enableJtagBoundaryScan = !eqps.enableJtagBoundaryScan;
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
eqps.setAddr(props.jtagAddr);
|
||||
eqps.setPort(props.jtagPort);
|
||||
});
|
||||
async function getIDCode(isQuiet: boolean = false) {
|
||||
jtagIDCode.value = await eqps.jtagGetIDCode(isQuiet);
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (
|
||||
z.string().ip().safeParse(props.jtagAddr).success &&
|
||||
z.number().positive().safeParse(props.jtagPort).success
|
||||
)
|
||||
watchEffect(async () => {
|
||||
if (eqps.setAddr(props.jtagAddr) && eqps.setPort(props.jtagPort))
|
||||
getIDCode(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user