Skip to content

Commit

Permalink
Fix bug with parsing UART output (eclipse-cdt-cloud#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
XingMicrochip authored Nov 21, 2023
1 parent 89cdd9c commit 59af421
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,12 @@ export class GDBTargetDebugSession extends GDBDebugSession {
this.socket = new Socket();
this.socket.setEncoding('utf-8');

const eolChar: string =
uart.eolCharacter === 'CRLF' ? '\r\n' : '\n';

let tcpUartData = '';
this.socket.on('data', (data: string) => {
for (const char of data) {
if (char === eolChar) {
if (char === '\n') {
this.sendEvent(
new OutputEvent(tcpUartData + os.EOL, 'Socket')
new OutputEvent(tcpUartData + '\n', 'Socket')
);
tcpUartData = '';
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/integration-tests/test-programs/socketServer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const net = require('net');
const os = require('os');

// Create socket echo server.
const socketServer = new net.Server();
Expand All @@ -12,7 +13,7 @@ socketServer.on('connection', (connection) => {
});

// Echo "Hello World!"
connection.write('Hello World!\n');
connection.write(`Hello World!${os.EOL}`);
});

socketServer.on('close', () => {
Expand Down

0 comments on commit 59af421

Please sign in to comment.