translator, wb_editors
4344
правки
Matveevrj (обсуждение | вклад) (Новая страница: «cells: { 'working on battery' : { type : "switch", value : false, readonly : true }, 'Vin' : { type : "voltage", value : 0 }») |
Matveevrj (обсуждение | вклад) (Новая страница: «defineRule("_rs485_switch_off", { asSoonAs: function () { return !dev.rs485_cmd.enabled; }, then: function() { runShellCommand("/usr/bin/printf '\\xff\\xff\\x0a\\x01\\x00\\x00\\x00\\x0b' >/dev/ttyNSC0"); } });») |
||
Строка 759: | Строка 759: | ||
Note the double shielding. | Note the double shielding. | ||
7. Putting it all together | |||
7. | |||
The full contents of the file with the rules: | |||
<syntaxhighlight lang="ecmascript"> | <syntaxhighlight lang="ecmascript"> | ||
defineVirtualDevice("rs485_cmd", { | defineVirtualDevice("rs485_cmd", { | ||
Строка 778: | Строка 773: | ||
} | } | ||
}); | }); | ||
function setup_port() { | function setup_port() { | ||
runShellCommand("stty -F /dev/ttyNSC0 ospeed 9600 ispeed 9600 raw clocal -crtscts -parenb -echo cs8"); | runShellCommand("stty -F /dev/ttyNSC0 ospeed 9600 ispeed 9600 raw clocal -crtscts -parenb -echo cs8"); | ||
} | } | ||
defineRule("_rs485_switch_on", { | defineRule("_rs485_switch_on", { | ||
asSoonAs: function () { | asSoonAs: function () { | ||
Строка 795: | Строка 786: | ||
} | } | ||
}); | }); | ||
defineRule("_rs485_switch_off", { | defineRule("_rs485_switch_off", { | ||
asSoonAs: function () { | asSoonAs: function () { | ||
Строка 806: | Строка 795: | ||
} | } | ||
}); | }); | ||
setTimeout(setup_port, 1000); // set setup_port() running 1 second after starting. | |||
setTimeout(setup_port, 1000); // | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Sending a message via Telegram bot == | |||
{{Anchor|telegram}} | {{Anchor|telegram}} | ||
Messages are sent using [https://core.telegram.org/api#telegram-api Telegram API] via <code>curl</code>. | |||
<div lang="ru" dir="ltr" class="mw-content-ltr"> | <div lang="ru" dir="ltr" class="mw-content-ltr"> |