- Echo 1 2 – A Powerful Http(s) Service Test Tool Harbor Freight
- Echo 1 2 – A Powerful Http(s) Service Test Tool Kit
- Echo 1 2 – A Powerful Http(s) Service Test Tool For A
- Echo 1 2 – A Powerful Http(s) Service Test Tool Free
- If it's a 5 V model, you can probably get away with powering it from the 5 V pin on the Pi, provided it has a sufficiently powerful PSU - in this case connect the GND input to one of the ground pins on the Pi, and VDC to the Pi's 5 V pin.
- @echo off echo%1 echo%2 echo%3 If the above batch script is stored in a file called test.bat and we were to run the batch as. Test.bat 1 2 3 Following is a screenshot of how this would look in the command prompt when the batch file is executed. The above command produces the following output. 1 2 3 If we were to run the batch as.
- 2Dependencies
Purpose
Pro Attachment Series™ ECHO Pro Attachment SeriesThe Expandable Multi-Task Tool! FlashAKit One S, a Tool/Utility for the HTC One S Contributors Flashalot Version Information Status: Stable Current Stable Version: 1.0.0 Stable Release Date: 2013-11-15 Created 2013-11-16 Last Updated 2013-11-15.
If you're not using the on-board audio, you can take advantage of the hardware Pulse Width Modulation capabilities of the Raspberry Pi to control the speed of a small PC fan, based on the system temperature. The fan's status is monitored and logged in Domoticz (and in the syslog). Note that this script is not dependent on Domoticz in any way other than for monitoring. It is launched and runs independently, so that if Domoticz should stop running, for whatever reason, the script will continue to quietly do its thing, keeping your system cool.
Dependencies
First you'll need to get the PWM activated, which unfortunately isn't as straightforward as one might think; the hardware PWM clock is not initialised at boot, and by default only starts up when the on-board soundcard is in use. There is however an alternative Device Tree Overlay, which activates the hardware PWM clock for general use, see the following guide for how to install it: Using the Raspberry Pi hardware PWM timers. You could of course use a 'soft' PWM instead, but these eat up precious CPU cycles, which seems unnecessary when you just want to change the speed of a fan - so this guide assumes the hardware PWM route.
Once you have installed and activated the pwm-with-clk.dtbo overlay linked to above, you should be able to test the PWM by doing (in a root shell):
Domoticz configuration
To be able to monitor the fan status in Domoticz, you need to create a 'virtual sensor' of the type 'Alert'. Call it 'Fan Status' for example, and make note of its index number (shown on the 'Devices' page in Domoticz).
Hardware
If you have access to an oscilloscope, correct functioning of the hardware PWM can be verified by hooking it up to the pin you chose when enabling the overlay (pwm0 defaults to GPIO_18). Otherwise, you can hook up an LED with a small series resistor (270 Ω) between the PWM pin and a GND pin; by modifying the 'duty_cycle' value above you should see the light intensity change. But an output pin on a Raspberry Pi is not powerful enough to directly drive a fan, nor is the voltage sufficient for most PC type fans, which tend to run on 12 V DC (though 5 V varieties also exist). So we will need some external cicuitry to give it a bit more brawn:
Suggested components:
- Q1: any small N-channel MOSFET (e.g. 2N7000/BS170)
- R1: 10 kΩ resistor
- C1: 0.1 uF electrolytic capacitor
- D1: Any small rectifier diode
Nothing too complicated going on there; Q1 will be switched on/off by the PWM signal from the Pi, C1 & D1 smooth out transients, while R1 keeps the MOSFET gate from floating. You can build this on an 8x4 piece of stripboard:
The 'RPM' line is just a straight through connection, in case you want to use a 3-pin fan with tachometer output. You can connect this to an input pin on the RasPi if you want to read it, but you'll need to enable the internal pull-up resistor for it to work (the tachometer output on PC fans is an open collector).
To connect it up, run a wire from the PWM output pin on the Pi (the default is GPIO_18 for pwm0, though you can change this in /boot/config.txt) to the PWM input connector on the stripboard. If your fan is a 12 V model you'll need a separate 12 V power supply, which you connect to the GND and VDC inputs. If it's a 5 V model, you can probably get away with powering it from the 5 V pin on the Pi, provided it has a sufficiently powerful PSU - in this case connect the GND input to one of the ground pins on the Pi, and VDC to the Pi's 5 V pin.
Optionally, if you want to monitor the fan's rotational speed, connect a wire from an input pin on the Pi to the RPM pin on the stripboard, and activate its internal pull-up resistor. Since it's not possible to do this from a Bash script, this functionality is not currently supported by the script featured here. If you want to include RPM monitoring you'll need to install a GPIO library, such as WiringPi, and modify the script to count RPM pulses, and report these to Domoticz in a separate virtual sensor.
Installation instructions
Assuming you have followed the instructions for activating the PWM hardware clock at boot, all you need to do is copy the script below into a new file on your Pi, change the 'fan_idx' to the index of the Domoticz alert sensor you want to use for monitoring, and make it executable:
You can now test the script by running:
Leave the script running, and in another terminal run (for example) 'stress' to load the CPU, causing it to heat up:
You should see the fan start spinning, and after stopping 'stress', eventually stop. You should also see the status of the 'alert' sensor you set up in Domoticz change when the fan status changes. Open the script and edit the temperature breakpoints, and low/high fan-speeds to suit. Note that the fan-speed should never exceed the 'period' value ('period' is the PWM frequency in nanoseconds, so 100000 is 1 kHz), and if you set it too low it may not provide enough energy for the fan to start.
Finally, you probably want to launch this script at boot, and leave it running in the background. On a Systemd Linux distribution (like Raspbian), this is very simple; create a new file in /etc/systemd/system/ called fancontrol.service:
Serial box 2015 10 download free. And paste the following into it:
Again, make this executable with:
You then need to tell Systemd about the new service, and enable it to run at boot:
That's all there is to it - you can now try rebooting your system and checking if the fancontrol service is running with:
Script with comments
Link to forum post
There is a topic in the forum if you wish to discuss this script, or if you need help getting it to work: Raspberry Pi hardware PWM fan control and monitoring.
--Lomax (talk) 18:38, 5 February 2017 (CET)
Lazy JavaScript Evaluator
for Shell Scripts
Basho lets you to write complex shell tasks using plain JavaScript. It mixes well with shell commands and scripts; so you can choose the best tool for the job.
Install basho first.
If you have npm > 5.2.0, you can use the npx command to try basho without installing.
Basics#
Basho evaluates a pipeline of instructions left to right. Instructions can be JavaScript code, reference to an external JS file, or a shell command. What makes basho interesting is Lazy Evaluation, more on this later.
To evaluate a JavaScript expression, use the 'js' option -j. Let's start with a single item in the pipeline, a JavaScript constant.
The option -j can be omitted for the first expression.
The option -p avoids printing the final result. I am not sure where you'd need to use it, but it's there.
Working with strings will need quoting, since bash will chew the quotes for itself. So you'll need to use single quotes around your double quotes.
Piping Results#
You can pipe an expression into a subsequent expression. The variable ‘x' is always used as a placeholder for receiving the previous input.
Quoting expressions#
If an expression has spaces, it is important to quote it. In the following example, see how 'x + 100' is quoted.
Similarly, if an expression contains bash special characters it is necessary to quote them. In the following example, the expression is quotes since '>' is the bash redirection operator.
As a best practice, it is wise to quote all expressions (except maybe the trivially simple).
Lazy evaluation and exit conditions#
You may choose to terminate the pipeline with the 'terminate' option -t when a condition is met. Since the pipeline is lazy, further expressions (or bash commands) are not evaluated.
Shell Commands#
Execute shell commands with the 'execute' option -e. The shell command is expanded as a JS template string, with the variable ‘x' holding the input from the preceding command in the pipeline. Remember to quote or escape characters which hold a special meaning in your shell, such as $, >, <, |, () etc.
Tip: Single quotes are far easier to work with, since double quotes will try toexpand $variables inside it.
You can extend the pipeline further after a shell command. The shell command's output becomes the input for the next command.
basho can receive input via stdin. As always, ‘x' represents the input.
You can pipe multi-line output from other commands.
There's nothing stopping you from piping basho's output either.
Importing JS files#
You can import a function from a JS file or an npm module with the --import option. The --import option takes two parameters; a filename or module name and an alias for the import. An import is available in all subsequent expressions throughout thepipeline.
Arrays, map, filter, flatMap and reduce#
If the input to an expression is an array, the subsequent expression or command is executed for each item in the array. It's the equivalent of a map() function.
Gambling quotes from movies. An input can also be an object, which you can expand in the template string.
You can use an Array of objects.
Array of arrays, sure.
If the input is an array, basho processes each item one-by-one (like a map() function). But sometimes, you want to process the entire array at once. Use the -a option for this.
Filter arrays with the 'filter' option -f.
Reduce with the 'reduce' option -r. The first parameter is the lambda, the second parameter is the initial value of the accumulator.
There's also the 'flatMap' option -m.
A flatMap can be used to flatten an array of arrays as well.
Btw, you could also access an array index in the template literal as thevariable ‘i' in lambdas and shell command templates.
Arguments and Reusable Expressions#
Sometimes you want to pass additional arguments or reuse an expression multiple times in the pipeline. You can define expressions with the 'define' option -d and they get stored as fields in a variable named 'k'. https://wvmjmh.over-blog.com/2021/01/pc-keyboard-mac-option-key.html. See usage below.
Here's how to use the define option to pass arguments
Here's how to use it for reusable expressions.
Can be used in shell commands as well. Remember to quote though.
Subroutines#
Subroutines are mini-pipelines within a parent pipeline. This allows us to define a set of operations which could be repeatedly called for each item.
Subroutines are defined with the --sub option followed by the name of the sub. The sub continues till an --endsub is found. The sub is stored for subsequent usage is the variable 'k'.
Nested Subroutines? Sure.
Named expressions, Seeking and Combining expressions#
The 'name' option -n gives a name to the result of the expression, so that you can recall it later with the -s (seek) or -c (combine) options.
Echo 1 2 – A Powerful Http(s) Service Test Tool Harbor Freight
The -s option allows you to seek a named result. Macaw 1 5 – code savvy web design tool.
The -c option allows you to combine/multiplex streams into an sequence of arrays.
Recursion#
The 'goto' option -g allows you to recurse to a previous named expression. It takes two parameters; (1) an expression name and (2) a predicate which stops the recursion.
Here's an expression that keeps recursing and adding 100 till it exceeds 1000.
Recursion is powerful. For instance, along with a promise that sleeps for a specified time, recursion can use used to periodically run a command. Usage is left to the reader as an exercise.
Multi-line string inputs and JSON Parsing#
With the 'string' option --str basho can treat the entire input as a single string with newlines (instead of an array of lines).
If the input is JSON, there's a convenient shortcut so that you don't have to write JSON.parse. The 'json' option --json.
Promises!#
If an JS expression evaluates to a promise, it is resolved before passing it to the next command in the pipeline.
Logging#
You can add a 'log' option -l anywhere in the pipeline to print the current value. Prints a newline at the end.
Echo 1 2 – A Powerful Http(s) Service Test Tool Kit
The 'write' option -w does the same thing as -l, but without the newline.
Error Handling#
You can handle an error with the --error option, and choose to return an arbitrary value in its place. If unhandled, the pipeline is terminated immediately. In the following example, x.split() results in an exception on the second input (10) since a number does have the split() method. The error handler expression replaces the exception with the string 'skipped'.
If the first argument to basho is --ignoreerror, basho will not exit on error. It will simply move to the next item.
The --printerror option works like --ignoreerror, but prints the error.
Note that ignoreerror and printerror must not be preceded by any option except the --import option.
Real world examples#
Count the number of occurences of a word in a line of text.
Recursively list all typescript files
Count the number of typescript files
Get the weather in bangalore
Who wrote Harry Potter and the Philosopher's Stone?
Find all git hosted sub directories which might need a pull
Find all git hosted sub directories which need to be pushed to remote
Check if basho version is at least 0.0.43
Here Documents for complex commands#
Complex commands require a lot of quoting which makes code ugly. Fortunately, a shell feature called Here Documents hugely simplifies this use case. You can pretty much avoid all quoting!
Note that you need to specify each argument in a separate line (which helps readability as well). And when invoking basho, remember to use quotes around the variable (see example below). Indentation is ignored, so you can use it for formatting.
Asterisks don't get substituted - if you need substitution, use <
Brackets#
For better legibility in multi-line commands, brackets can help. Cyberline racing 1 0. A line containing an opening or closing bracket should contain nothing else, as in the example below. Brackets cannot be nested.
Echo 1 2 – A Powerful Http(s) Service Test Tool For A
Basho Recipes#
This is work in progress, but you can see more real world examples at https://bashojs.org/recipes. To contribute recipes, fork https://github.com/bashojs/basho-recipes and send a pull request.
About#
Echo 1 2 – A Powerful Http(s) Service Test Tool Free
Basho is developed by @jeswin - sponsored by AgileHead. This software has an MIT license. You can freely use it in commercial work without restrictions.
That's it#
Typing basho without any parameters does nothing but might make you happy. Or reflective. This of course, is the original purpose of this app.