Starting on v1.24.0; first change: support for encoding ESC characters in SerialPort test strings (support which perhaps should eventually be moved into getComponentParms() instead)
This commit is contained in:
parent
9d289b54da
commit
145ec9d125
213 changed files with 256 additions and 235 deletions
|
|
@ -325,10 +325,31 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
|||
* that do not conflict with predefined controls (which, of course, is the only way you can get here).
|
||||
*/
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
/*
|
||||
* Convert any "backslashed" sequences into the appropriate control characters.
|
||||
* Backslash sequences like \n, \r and \\ have already been converted to LF, CR and backslash
|
||||
* characters, by virtue of the eval() function that all our component parameter strings pass through;
|
||||
* eval() treats strings like "source code", so any backslash sequence that JavaScript supports is
|
||||
* automatically converted.
|
||||
*
|
||||
* The complete list of supported backslash sequences:
|
||||
*
|
||||
* \0 \' \" \\ \n \r \v \t \b \f \uXXXX \xXX
|
||||
*
|
||||
* We also want to support some additional sequences, like backslash-e for ESC. Only one problem: for
|
||||
* any unrecognized backslash sequence, eval() simply removes the backslash. So we have to double-backslash
|
||||
* it, which eval() will replace with a single backslash.
|
||||
*
|
||||
* So, additional supported backslash sequences include:
|
||||
*
|
||||
* \\e (ESC)
|
||||
*
|
||||
* Note that I've judiciously avoided using terms "escape notation" or "escape sequence" to talk about
|
||||
* these sequences, because ESC is one of the additional characters I want to support, and using the word
|
||||
* "escape" in both contexts is WAY confusing.
|
||||
*/
|
||||
sValue = sValue.replace(/\\n/g, "\n").replace(/\\r/g, "\r");
|
||||
sValue = sValue.replace(/\\e/g, String.fromCharCode(0x1b));
|
||||
|
||||
control.onclick = function onClickTest(event) {
|
||||
serial.receiveData(sValue);
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue