Skip to content

Commit

Permalink
style: 🚨 fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
meisZWFLZ committed Dec 6, 2023
1 parent f502039 commit da58c20
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 131 deletions.
42 changes: 21 additions & 21 deletions src/VexConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class VexSerialConnection extends VexEventTarget {

this.writer = this.port.writable.getWriter();
this.reader = this.port.readable.getReader();
this.startReader();
void this.startReader();

return true;
} catch (e) {
Expand All @@ -176,10 +176,10 @@ export class VexSerialConnection extends VexEventTarget {
resolve: (data: HostBoundPacket | ArrayBuffer | AckType) => void,
timeout: number = 1000,
): void {
void this.writeDataSync(rawData, timeout).then(resolve);
void this.writeDataAsync(rawData, timeout).then(resolve);
}

async writeDataSync(
async writeDataAsync(
rawData: DeviceBoundPacket | Uint8Array,
timeout: number = 1000,
): Promise<HostBoundPacket | ArrayBuffer | AckType> {
Expand Down Expand Up @@ -324,12 +324,12 @@ export class VexSerialConnection extends VexEventTarget {
}

async query1(): Promise<Query1ReplyD2HPacket | null> {
const result = await this.writeDataSync(new Query1H2DPacket(), 100);
const result = await this.writeDataAsync(new Query1H2DPacket(), 100);
return result instanceof Query1ReplyD2HPacket ? result : null;
}

async getSystemVersion(): Promise<VexFirmwareVersion | null> {
const result = await this.writeDataSync(new SystemVersionH2DPacket());
const result = await this.writeDataAsync(new SystemVersionH2DPacket());
return result instanceof SystemVersionReplyD2HPacket
? result.version
: null;
Expand All @@ -344,32 +344,32 @@ export class V5SerialConnection extends VexSerialConnection {
];

async getDeviceStatus(): Promise<GetDeviceStatusReplyD2HPacket | null> {
const result = await this.writeDataSync(new GetDeviceStatusH2DPacket());
const result = await this.writeDataAsync(new GetDeviceStatusH2DPacket());
return result instanceof GetDeviceStatusReplyD2HPacket ? result : null;
}

async getRadioStatus(): Promise<GetRadioStatusReplyD2HPacket | null> {
const result = await this.writeDataSync(new GetRadioStatusH2DPacket());
const result = await this.writeDataAsync(new GetRadioStatusH2DPacket());
return result instanceof GetRadioStatusReplyD2HPacket ? result : null;
}

async getSystemFlags(): Promise<GetSystemFlagsReplyD2HPacket | null> {
const result = await this.writeDataSync(new GetSystemFlagsH2DPacket());
const result = await this.writeDataAsync(new GetSystemFlagsH2DPacket());
return result instanceof GetSystemFlagsReplyD2HPacket ? result : null;
}

async getSystemStatus(
timeout = 1000,
): Promise<GetSystemStatusReplyD2HPacket | null> {
const result = await this.writeDataSync(
const result = await this.writeDataAsync(
new GetSystemStatusH2DPacket(),
timeout,
);
return result instanceof GetSystemStatusReplyD2HPacket ? result : null;
}

async getMatchStatus(): Promise<MatchStatusReplyD2HPacket | null> {
const result = await this.writeDataSync(new GetMatchStatusH2DPacket());
const result = await this.writeDataAsync(new GetMatchStatusH2DPacket());
return result instanceof MatchStatusReplyD2HPacket ? result : null;
}

Expand Down Expand Up @@ -445,7 +445,7 @@ export class V5SerialConnection extends VexSerialConnection {

let nextAddress = loadAddress ?? USER_FLASH_USR_CODE_START;

const p1 = await this.writeDataSync(
const p1 = await this.writeDataAsync(
new InitFileTransferH2DPacket(
FileInitAction.READ,
downloadTarget,
Expand Down Expand Up @@ -479,7 +479,7 @@ export class V5SerialConnection extends VexSerialConnection {
lastBlock = true;
}

const p2 = await this.writeDataSync(
const p2 = await this.writeDataAsync(
new ReadFileH2DPacket(nextAddress, bufferChunkSize),
3000,
);
Expand All @@ -496,7 +496,7 @@ export class V5SerialConnection extends VexSerialConnection {
nextAddress += bufferChunkSize;
}

await this.writeDataSync(
await this.writeDataAsync(
new ExitFileTransferH2DPacket(FileExitAction.EXIT_HALT),
30000,
);
Expand Down Expand Up @@ -548,7 +548,7 @@ export class V5SerialConnection extends VexSerialConnection {

console.log("init file transfer", filename);

const p1 = await this.writeDataSync(
const p1 = await this.writeDataAsync(
new InitFileTransferH2DPacket(
FileInitAction.WRITE,
downloadTarget,
Expand All @@ -566,7 +566,7 @@ export class V5SerialConnection extends VexSerialConnection {
console.log(p1);

if (linkedFile !== undefined) {
const p3 = await this.writeDataSync(
const p3 = await this.writeDataAsync(
new LinkFileH2DPacket(
linkedFile.vendor ?? FileVendor.USER,
linkedFile.filename,
Expand Down Expand Up @@ -600,7 +600,7 @@ export class V5SerialConnection extends VexSerialConnection {
lastBlock = true;
}

const p2 = await this.writeDataSync(
const p2 = await this.writeDataAsync(
new WriteFileH2DPacket(nextAddress, tmpbuf),
3000,
);
Expand All @@ -616,7 +616,7 @@ export class V5SerialConnection extends VexSerialConnection {
nextAddress += bufferChunkSize;
}

const p4 = await this.writeDataSync(
const p4 = await this.writeDataAsync(
new ExitFileTransferH2DPacket(
autoRun ? FileExitAction.EXIT_RUN : FileExitAction.EXIT_HALT,
),
Expand All @@ -627,7 +627,7 @@ export class V5SerialConnection extends VexSerialConnection {
}

async setMatchMode(mode: MatchMode): Promise<MatchModeReplyD2HPacket | null> {
const result = await this.writeDataSync(
const result = await this.writeDataAsync(
new UpdateMatchModeH2DPacket(mode, 0),
);
return result instanceof MatchModeReplyD2HPacket ? result : null;
Expand All @@ -636,14 +636,14 @@ export class V5SerialConnection extends VexSerialConnection {
async loadProgram(
value: SlotNumber | string,
): Promise<LoadFileActionReplyD2HPacket | null> {
const result = await this.writeDataSync(
const result = await this.writeDataAsync(
new LoadFileActionH2DPacket(FileVendor.USER, FileLoadAction.RUN, value),
);
return result instanceof LoadFileActionReplyD2HPacket ? result : null;
}

async stopProgram(): Promise<LoadFileActionReplyD2HPacket | null> {
const result = await this.writeDataSync(
const result = await this.writeDataAsync(
new LoadFileActionH2DPacket(FileVendor.USER, FileLoadAction.STOP, ""),
);
return result instanceof LoadFileActionReplyD2HPacket ? result : null;
Expand All @@ -654,7 +654,7 @@ export class V5SerialConnection extends VexSerialConnection {
y: number,
press: boolean,
): Promise<SendDashTouchReplyD2HPacket | null> {
const result = await this.writeDataSync(
const result = await this.writeDataAsync(
new SendDashTouchH2DPacket(x, y, press),
);
return result instanceof SendDashTouchReplyD2HPacket ? result : null;
Expand Down
Loading

0 comments on commit da58c20

Please sign in to comment.