Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings.log, off,display,log, both #2549

Merged
merged 5 commits into from Feb 9, 2023
Merged

Conversation

hughbarney
Copy link
Contributor

I have attempted to modify settings app and bootupdate.js to handle debug settings
so that you can have 0=off, 1=display, 2=log, 3=both
I have tested but still get stuff drawn on the screen using log when there should be no output to the screen
so not 100% that I have covered all the bases.
Pull request so you have have a look at my code.

@hughbarney
Copy link
Contributor Author

When set to log (2) the boot0 code has

_DBGLOG=require("Storage").open("log.txt","a");
_DBGLOG=require("Storage").open("log.txt","a");
LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);});

I suspect the logging to the console is happening due to the Terminal.write(d);

@gfwilliams
Copy link
Member

Hi - yes, I think this is broken.

I suspect the logging to the console is happening due to the Terminal.write(d);

Yes, it will be. To log, you'll need the console on Loopback. So you want:

  • Loopback.setConsole for log = 2/3
  • Terminal.write(d) only for log = 3

Also:

if (s.log>=2) ...
else if (s.log==1||s.log==3) 

doesn't work anyway because of log==3 the second bit is never hit. I'll make a change to the PR and maybe you can test it?

@gfwilliams
Copy link
Member

Sorry - made a mess of that. I think it's ok now. The original code isn't ideal as it's quite duplicated - you've basically got 8 modes - the 4 log modes, but then when programmable=true and =false

@hughbarney
Copy link
Contributor Author

hughbarney commented Feb 1, 2023

I was not entirely sure what you did here, you seem to adjust my pull request.

To test I decided to download the raw file of bootupdate.js and upload it to my Bangle through the IDE.

TEST 1 (log )
I set the debug setting to log (ie =2) and loaded simplest.app.js with a console.log("Simplest") in the draw function.
Disconnected from the IDE and then reloaded simplest etc.

For 3 minutes I watched the watch face and could not see any debuig messages printed.
To download log.txt I had to reconnect to the IDE I then saw a debug message displayed on the bottom of the screen.
The only way to clear that is to long button reset , load a different watch, then I reselected simplest clock.
After that no other debug appears.

TEST 2 (display)
Set setting to Debug=display at 21:04, then watched simplest redraw every minute and display a 1 line message at the end of the draw call(). Did this until 21:07 and check that no messages were logged with those timestamps in log.txt.

TEST 3 (both)
Set settings to Debug=both.
From 21:11 to 21:13 - can see messages on the screen
COuld also see them in the log.txt

CONCLUSION: It appears to be working, but connecting to the IDE means you get some debug printed to the watch screen on connection until you reload an app.

I think that is to be expected from what you wrote in the Forum thread ?

@gfwilliams
Copy link
Member

Ok, great - yes, that sounds good to me! Debug messages would have to go to Bluetooth when connected as otherwise the IDE/App Loader wouldn't function (normal messages go via the same channel).

I guess the programmable:off case hasn't been tested - part of me wonders if logging with programmable:off should just be removed though as it seems like quite a rare case.

@hughbarney
Copy link
Contributor Author

Gordon - its your call. I would remove it on the basis that if you are debugging something then more than likely you will have switch programmable on. I never switch programmable off on mine, I'm just not that paranoid that someone on a train is going to hack my watch :)

@gfwilliams gfwilliams merged commit e61c6f2 into espruino:master Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants