diff --git a/src/connections/pyserial.ts b/src/connections/pyserial.ts index 911e4b4..ce1a013 100644 --- a/src/connections/pyserial.ts +++ b/src/connections/pyserial.ts @@ -125,7 +125,7 @@ export default class PySerial implements ConnectionTarget { } public async send(mssg: string, drain: boolean = true): Promise { - let data = Buffer.from(mssg, 'binary'); + let data = Buffer.from(mssg, 'utf8'); await this.streamWrite(data); diff --git a/src/rp2/sync.ts b/src/rp2/sync.ts index bc786fa..61d653b 100644 --- a/src/rp2/sync.ts +++ b/src/rp2/sync.ts @@ -190,12 +190,12 @@ export default class Sync { await this.startSync(oncomplete, 'send', files); } - public async startReceive(oncomplete: Function, files: string) { + public async startReceive(oncomplete: Function, files?: string) { await this.settings.refresh(); await this.startSync(oncomplete, 'receive', files); } - private async startSync(oncomplete: Function, method: string, files: string) { + private async startSync(oncomplete: Function, method: string, files?: string) { this.logger.info('Start sync method ' + method); this.fails = 0; this.method = method; diff --git a/src/serialDolmatcher.ts b/src/serialDolmatcher.ts index f192dbc..fbcd2fd 100644 --- a/src/serialDolmatcher.ts +++ b/src/serialDolmatcher.ts @@ -48,7 +48,7 @@ export default class SerialDolmatcher extends EventEmitter { private outputHidden: boolean; private status: number; private _fileSystems: any; - private syncObj: any; + private syncObj?: Sync; private ftpServer?: FtpSrv; private _fs?: FtpFileSystem; private firstTimeStart?: boolean; @@ -479,7 +479,7 @@ export default class SerialDolmatcher extends EventEmitter { if (this.isSynchronizing()) { this.terminal?.writeln('An error occurred: ' + message); this.logger.warning('Synchronizing, stopping sync'); - await this.syncObj.stop(); + await this.syncObj?.stop(); } } else { this.terminal?.writeln( @@ -712,7 +712,7 @@ export default class SerialDolmatcher extends EventEmitter { await this.syncObj.startReceive(cb); } else { try { - await this.syncObj.startSend(cb, files); + await this.syncObj?.startSend(cb, files); } catch (e) { console.log(e); } @@ -753,7 +753,7 @@ export default class SerialDolmatcher extends EventEmitter { let type = this.synchronizeType === 'receive' ? 'download' : 'upload'; this.terminal?.writeln('Stopping ' + type + '....'); - await this.syncObj.stop(); + await this.syncObj?.stop(); this.stopOperation(); } }