Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
blocks:drivers:troubleshooting [2018-01-12 19:54] admin created |
blocks:drivers:troubleshooting [2024-10-25 06:00] (current) admin Bad link |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Troubleshooting ===== | + | ====== Troubleshooting ====== |
+ | This article provides some pointers on what to do when a driver doesn' | ||
- | ==== Driver Script | + | ===== Loading |
- | ==== Runtime Errors ==== | + | There may be syntax errors, or other fatal errors, that stop your driver from getting off the ground. While the TypeScript language, compiler and associated development tools, help you out with avoiding and fixing many errors, such errors can still occur in ways that are undetected by the development tools. |
- | ==== Logging ==== | + | :!: You're strongly advised to test a new driver on your local computer before deploying it to a production Blocks server. A poorly written driver can cause the server to misbehave, and may affect the performance of other functions in Blocks. |
+ | If a driver doesn' | ||
+ | |||
+ | PIXILAB-Blocks-root/ | ||
+ | |||
+ | Open a terminal window (" | ||
+ | |||
+ | tail -20 -f latest.log | ||
+ | |||
+ | Or, under Windows Powershell: | ||
+ | |||
+ | Get-Content latest.log –Wait | ||
+ | |||
+ | This shows the last few lines of the log file, which may reveal any errors encountered loading the driver. | ||
+ | |||
+ | |||
+ | ===== Runtime Errors ===== | ||
+ | |||
+ | The driver may load OK, but yet malfunction at some point. Here too, the log file is your best friend. Keep a close eye on the log file while using the driver to see if any errors appear related to the driver. | ||
+ | |||
+ | In some cases, errors may be triggered by data received from the device being controlled. Hence, you may need to exercise all functions of the driver to see if any errors occur. | ||
+ | |||
+ | ===== Writing Log Messages ===== | ||
+ | |||
+ | While developing a driver, you may want to display its internal state to see how it's behaving. You can use any of the standard // | ||
+ | |||
+ | :!: In order to see the output of //log, info// or //warn//, you must increase the log level, as described below. | ||
+ | |||
+ | < | ||
+ | /** Log functions take one or many values, which will be concatenated | ||
+ | with a space as separator. | ||
+ | */ | ||
+ | interface console { | ||
+ | log(...toLog: | ||
+ | info(...toLog: | ||
+ | error(...toLog: | ||
+ | warn(...toLog: | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | :!: You may want to remove, or comment out, any logging calls in your driver once you get it working. This avoids unwanted noise in the log file, and may slightly improve the performance of your driver. | ||
+ | ==== Increasing the Log Level ==== | ||
+ | |||
+ | Most troubleshooting methods involve viewing Blocks log file. By default, this log file contains only errors encountered while running Blocks. In some cases, you may want to increase the verbosity of the logging. This can be done by adding the following lines to a file named // | ||
+ | |||
+ | < | ||
+ | # Logging verbosity level. Specify one of ERROR, WARN, INFO | ||
+ | logging: | ||
+ | loggers: | ||
+ | Script: INFO # Verbose logging for scripts/ | ||
+ | </ | ||
+ | |||
+ | If the file doesn' | ||
+ | |||
+ | :!: Setting the logging level to INFO may write lots of details to the log file. While you may want it set to INFO while developing drivers, or to troubleshoot other issues, you should set it back to WARN or ERROR for normal use of Blocks. | ||
+ | ===== Viewing the Log Remotely ===== | ||
+ | |||
+ | While a separate development computer is preferable for driver development, | ||
+ | |||
+ | ==== Archived Log Files ==== | ||
+ | |||
+ | If you want to investigate an error that occurred some time ago, the information may no longer be in the // | ||
+ | |||
+ | ===== Reloading Changes Automatically ===== | ||
+ | |||
+ | When you change drivers, you must normally restart Blocks for those changes to take effect. As this can make the development more time consuming, an alternative is to enable automatic reloading of scripts. This is also done in the // | ||
+ | |||
+ | < | ||
+ | scripting: | ||
+ | watchFiles: true | ||
+ | </ | ||
+ | |||
+ | Remember to restart Blocks after changing the // |