Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Conversation

BelKed
Copy link
Contributor

@BelKed BelKed commented Jan 23, 2022

Now you can print timestamp before each line of Serial Monitor output.
Format of timestamp can be changed using command "Arduino: Change Timestamp Format" (arduino.changeTimestampFormat).
You can find list of all available placeholders here: https://strftime.org.


Example ("Timestamp Format" set to %H:%M:%S.%f -> ):

[Starting] Opening the serial port - /dev/cu.usbmodemFA131
17:13:18.016370 -> 0
17:13:19.019009 -> 1
17:13:20.018564 -> 2
17:13:21.018022 -> 3
17:13:22.017378 -> 4
17:13:23.020687 -> 5
...

This PR adresses these issues:

Warning! This PR depends on microsoft/serial-monitor-cli#10


@benmcmorran or @gcampbell-msft, please, could you review?

@fearthecowboy
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@BelKed BelKed requested a review from gcampbell-msft January 25, 2022 11:44
@@ -102,7 +105,7 @@ export class SerialPortCtrl {
this._child.stdout.on("data", (data) => {
if (this.isActive) {
const jsonObj = JSON.parse(data.toString())
this._bufferedOutputChannel.append(jsonObj["payload"] + "\n");
this._bufferedOutputChannel.append(jsonObj["timestamp"] + jsonObj["payload"] + "\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider here is forcing a certain "break" rather than allowing the user to set it. If there arises a scenario where the user wants to do something with the timestamp data, they might have trouble doing that along with formatting, since they'd have to parse out the extra characters.

i.e. Hard-code in the "->" and only let the user define the format of the time. This way they only get the time in the 'timestamp' json and they don't have to parse out the seperator characters. This would mean users only set '%H:%m:%s' for example, compared to now, where they can set '%H:%m:%s ->'

However, for how the extension currently uses it, what you have is fine and this comment won't block your PR.

@gcampbell-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@gcampbell-msft gcampbell-msft merged commit 1718768 into microsoft:main Jan 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants