Skip to content

Commit 9eec286

Browse files
committed
[bug]fix node send multi fc
1 parent 8cf39d8 commit 9eec286

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

src/cli/build.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import dllLib from '../../resources/lib/zlgcan.dll?asset&asarUnpack'
2+
import esbuild from '../../resources/bin/esbuild?asset&asarUnpack'
23

3-
let esbuild_executable: any
4-
5-
const loadEsbuild = async () => {
6-
if (process.platform === 'win32') {
7-
esbuild_executable = await import('../../resources/bin/esbuild.exe?asset&asarUnpack')
8-
} else {
9-
esbuild_executable = await import('../../resources/bin/esbuild?asset&asarUnpack')
10-
//<-- May change fetch from node_modules esbuild_executable = await import('esbuild/bin/esbuild?asset&asarUnpack')
11-
}
4+
let esbuild_executable = esbuild
5+
if (process.platform === 'win32') {
6+
esbuild_executable = `${esbuild}.exe`
127
}
138

149
import path from 'path'

src/main/docan/cantp.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
} from '../share/can'
1515
import { queue, QueueObject } from 'async'
1616
import { CAN_SOCKET, CanBase } from './base'
17+
import { v4 } from 'uuid'
18+
import { i } from 'vite/dist/node/types.d-aGj9QkWt'
1719
export interface CanTp {
1820
close: () => void
1921
writeTp(addr: CanAddr, data: Buffer): Promise<number>
@@ -151,6 +153,7 @@ export class CAN_TP_SOCKET {
151153
}
152154

153155
export class CAN_TP implements CanTp {
156+
uuid: string
154157
base: CanBase
155158
cnt = 0
156159
event = new EventEmitter()
@@ -172,8 +175,9 @@ export class CAN_TP implements CanTp {
172175
}
173176
> = {}
174177
lastWriteError?: TpError
175-
constructor(base: CanBase) {
178+
constructor(base: CanBase, uuid?: string) {
176179
this.base = base
180+
this.uuid = uuid || v4()
177181
//close peak tp default handle
178182

179183
this.tpStatus = {}
@@ -265,7 +269,14 @@ export class CAN_TP implements CanTp {
265269
reject(new TpError(TP_ERROR_ID.TP_TIMEOUT_A, addr, data))
266270
}, addr.nAs)
267271
this.base
268-
.writeBase(addrToId(addr), addr, data)
272+
.writeBase(
273+
addrToId(addr),
274+
{
275+
...addr,
276+
uuid: this.uuid
277+
},
278+
data
279+
)
269280
.then((ts) => {
270281
clearTimeout(timer)
271282
resolve({ ts })
@@ -623,7 +634,12 @@ function baseHandle(val: CanMessage) {
623634
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
624635
//@ts-ignore
625636
const _this = this as { addr: CanAddr; id: number; inst: CAN_TP; listenOnly: boolean }
637+
638+
if (val.msgType.uuid == _this.inst.uuid) {
639+
return
640+
}
626641
const tpCmdId = _this.inst.getReadId(_this.addr)
642+
627643
const status = _this.inst.tpStatus[tpCmdId] || 0
628644
let index = 0
629645
if (

src/main/ipc/uds.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { BrowserWindow, ipcMain, shell } from 'electron'
22
import scriptIndex from '../../../resources/docs/.gitkeep?asset&asarUnpack'
3+
import esbuild from '../../../resources/bin/esbuild?asset&asarUnpack'
34

4-
let esbuild_executable: any
5-
6-
const loadEsbuild = async () => {
7-
if (process.platform === 'win32') {
8-
esbuild_executable = await import('../../../resources/bin/esbuild.exe?asset&asarUnpack')
9-
} else {
10-
esbuild_executable = await import('../../../resources/bin/esbuild?asset&asarUnpack')
11-
//<-- May change fetch from node_modules esbuild_executable = await import('esbuild/bin/esbuild?asset&asarUnpack')
12-
}
5+
let esbuild_executable = esbuild
6+
if (process.platform === 'win32') {
7+
esbuild_executable = `${esbuild}.exe`
138
}
149

1510
import path from 'path'

src/main/nodeItem.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,10 @@ export class NodeClass {
179179
for (const c of nodeItem.channel) {
180180
const canBaseItem = this.canBaseMap.get(c)
181181
if (canBaseItem && tester.type == 'can') {
182-
const tp = new CAN_TP(canBaseItem)
182+
const tp = new CAN_TP(canBaseItem, nodeItem.id)
183183
for (const [index, addr] of tester.address.entries()) {
184184
if (addr.type == 'can' && addr.canAddr) {
185-
const idT = tp.getReadId(
186-
addr.canAddr,
187-
nodeItem.isTest ? true : tester.simulateBy != nodeItem.id
188-
)
185+
const idT = tp.getReadId(addr.canAddr, tester.simulateBy != nodeItem.id)
189186
tp.event.on(idT, (data) => {
190187
if (data instanceof CanTpError) {
191188
//TODO:
@@ -210,7 +207,7 @@ export class NodeClass {
210207
if (index == 0) {
211208
const idR = tp.getReadId(
212209
swapAddr(addr.canAddr),
213-
nodeItem.isTest ? tester.simulateBy != nodeItem.id : true
210+
tester.simulateBy != nodeItem.id
214211
)
215212
tp.event.on(idR, (data) => {
216213
if (data instanceof CanTpError) {
@@ -293,7 +290,7 @@ export class NodeClass {
293290
if (ethBaseItem && tester.type == 'eth') {
294291
const baseItem = this.doips.find((d) => d.base.id == ethBaseItem.id)
295292
if (baseItem) {
296-
if (tester.simulateBy == nodeItem.id && !nodeItem.isTest) {
293+
if (tester.simulateBy == nodeItem.id) {
297294
baseItem.registerEntity(true, this.log)
298295
}
299296
for (const addr of tester.address) {

0 commit comments

Comments
 (0)