Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Questions / Bug Reports / Pull Requests welcome! https://github.com/billroy/bitlash/issues
This repository contains the Pinoccio-specific version of bitlash, see https://github.com/Pinoccio/library-bitlash
Bitlash supports string constants in function argument lists, but until now there hasn't been a way to distinguish such string arguments from numeric arguments once you're inside the called function, making it easy to reference forbidden memory by mistake.
The new isstr() Bitlash function helps handle this problem by letting you check the type of a specified argument to the function it's called in:
> function stringy {i=1;while (i<=arg(0)) {print i,arg(i),isstr(i);i++}}
saved
> stringy("foo",1,2,3,"bar","baz")
1 541 1
2 1 0
3 2 0
4 3 0
5 545 1
6 549 1
There is a corresponding C api for C User Functions:
numvar isstringarg(numvar);
And a companion to getarg() that fetches an argument but throws an error if the argument is not a string:
numvar getstringarg(numvar);
Here is an example sketch with a User Function called echo() that uses isstringarg() and getstringarg() to print string arguments separately from numeric ones. The echo() function echoes back its arguments, with proper handling for strings:
#include "Arduino.h"
#include "bitlash.h"
#include "src/bitlash.h" // for sp() and printInteger()
numvar func_echo(void) {
for (int i=1; i <= getarg(0); i++) {
if (isstringarg(i)) sp((const char *) getstringarg(i));
else printInteger(getarg(i), 0, ' ');
speol();
}
}
void setup(void) {
initBitlash(57600);
addBitlashFunction("echo", (bitlash_function) func_echo);
}
void loop(void) {
runBitlash();
}
NOTE: The changes consume a little space on the expression evaluation stack, so some complex expressions that formerly worked may see an expression overflow. Please report this if you see it.
Applied contributed Due patches; Bitlash should run on Due now. Thanks, Bruce.
Bumped copyright date in the startup banner.
Recent Bitlash changes of note:
Published a new tool, "bloader.js", a program loader and serial monitor for Bitlash based on node.js. See https://github.com/billroy/bloader.js
Published a new tool, "serial-web-terminal", which provides a browser-based serial terminal monitor for a usb-connected Arduino. See https://github.com/billroy/serial-web-terminal.git
Fixed a millis rollover bug in the background task scheduler. You can cherry-pick the fix at line 103 in src/bitlash-taskmgr.c -- also, there is a new example named examples/rollover that lets you set millis() to a value just before the rollover to test.
Added getkey([prompt]) and getint([prompt]) to get user input.
Compiles and runs on Linux and OS X, and there is a web-based Bitlash terminal you can run on Heroku so you can play with Bitlash in your browser. See README-UNIX.md
Compiles on the tiny core, with many feature amputations. Not tested. See README-TINY.md
Bitlash builds under the github working code for the new Arduino 1.5 IDE, both for the customary AVR targets and for the new ARM targets for the Arduino Due. You may still get errors with the current Arduino 1.5 beta until a refresh is announced. See the forum thread below to test using the latest github IDE code.
The ARM has no eeprom. Bitlash function storage in this alpha is in a 4k ram buffer that simulates EEPROM, except it vanishes at power-off.
Without a Due here, I cannot test it, but field reports are welcome.
Forum thread here: http://arduino.cc/forum/index.php/topic,128543.msg966899.html#msg966899
Let's call it "2.0"
The Bitlash User's Guide is available as a pdf book at: http://bitlash.net/bitlash-users-guide.pdf
Examples are updated for Arduino 1.0.1
Bitlash is now licensed under the MIT license
Released new wiki and landing page on Github
New morse and morse2 examples: printf() to morse, blocking and non-blocking
Check out the Textwhacker project at https://github.com/billroy/textwhacker for scrolling text output from Bitlash on a SparkFun LED matrix
Stalking Arduino 1.0: more #include fixes and warnings cleanup
The default for MAX_USER_FUNCTIONS is now 20 [bitlash-functions.c @ 268]
RF12 support for NanodeRF; see examples/bitlash_rf
Arduino 1.0 status
The BitlashWebServer example now works on Nanode, as well as the official shield
SD card support is, by default, disabled. To enable it:
printf() and fprintf() now respect the width argument, including leading 0:
printf("%3d\n", 99); 99 printf("%03d\n", 99); 099
You can define symbolic names for pins at compile time to suit your project
You can define built-in named functions in Bitlash script at compile time to suit your project
Runs scripts from SDCard file systems
Has a language worth running from a file
String arguments! printf("%d:%d:%d\n",h,m,s)
Can write SDFILE from script, too: fprintf("logfile.dat","%d:%d:%d\n",h,m,s)
Tested on and requires Arduino 0022
This version runs scripts from SDCARD as well as EEPROM
bitlashsd sd card demo REQUIRES SDFat Beta 20110604 available from:
download link: http://beta-lib.googlecode.com/files/SdFatBeta20110604.zip
to install, copy the "SDFat" library from the SDFatBeta distribution into the Arduino/libraries directory and restart Arduino
open the "bitlashsd" example and upload
to disable SDFILE support:
BUGFIX: 0xb broken by 0b1000! print 0xbbbbbbbb 0
BUGFIX: MAX_USER_FUNCTIONS error allowed only n-1 functions
BUGFIX: bloader.py was not well-synchronized at the start of a file upload as a result it could lose the first several lines of a file it now syncs correctly with the command prompt on the arduino
string arguments
unary & operator
unary * operator
// comments
doCommand()
printf("format string\n", "foo", "bar",3)
EXAMPLE: commands supported in the bitlashsd sd card demo
dir exists("filename") del("filename") create("filename", "first line\nsecondline\n") append("filename", "another line\n") type("filename") cd("dirname") md("dirname") fprintf("filename", "format string %s%d\n", "foo", millis);
- put your multi-line script on an SD card and run it from the command line
- example: bitlashcode/memdump
- example: bitlashcode/vars
- //comments work (comment to end of line)
- functions are looked up in this priority / order:
- internal function table
- user C function table (addBitlashFunction(...))
- Bitlash functions in EEPROM
- Bitlash functions in files on SD card
- beware name conflicts: a script on SD card can't override a function in EEPROM
- BUG: the run command only works with EEPROM functions
- it does not work with file functions
- for now, to use run with a file function, use this workaround:
- make a small EEPROM function to call your file function
- run the the EEPROM function
- startup and prompt functions on sd card are honored, if they exist
- you can upload files using bitlashcode/bloader.py
- python bloader.py memdump md
... uploads memdump as "md"
This release fixes a bug in RC1 which broke function definition in some cases.
Please report bugs to bill@bitlash.net
If the command defining the function was the last thing on a line, RC1 worked correctly:
function hello {print "Hello, world!"} <-- worked
If there were characters after the closing } of the function definition, the bug caused the function text to be mismeasured and spurious text would be appended to the function definition, causing it to fail in use:
> function hello { print "Hello, world!"}; <-- this is legal but it triggered bug in RC1
saved
> ls
function hello { print "Hello, world"}}; <-- BUG: extra } saved at the end
The function text is measured more accurately in RC2.
Users are encouraged to upgrade to fix this bug.
Existing functions may need to be fixed, as well. Make sure the {} balance.
Noting a behavior that may change in a future release: an attempt to define a function from within a function will fail silently or worse. Don't do that.
function foo {function bar{print "bar"};bar}; <-- don't do this!
> foo
saved
> ls
function foo {function bar{print "bar"};bar};
function bar {}; <-- sorry, doesn't work in 2.0
> bar
>
This isn't new: Bitlash 1.1 has the same internal implementation limitation, but it was nearly impossible for a human to get the backslash-quote combinations right to attempt the test.
Syntax overhaul: the Bitlash 2.0 language is considerably different, and old macros will need to be updated to run in v2
if (expression) { stmt;...;stmt;} else {stmt;...;stmt;} while (expression) { stmt; } switch (expression) { stmt0; stmt1; ... stmtN; } function hello {print "Hello, world!";}
Macros are now Functions, they take arguments and can return a value arg(0) is the count of args you got arg(1..n) are the args return expression; to return a value; zero is assumed User Functions in C use this same scheme now
Function (/macro) definition syntax has changed: function printmyargs {i=0; while ++i<arg(0) {print arg(i);}}
New Functions bc: bitclear bs: bitset br: bitread bw: bitwrite
New API calls setOutputHandler() api allows capture of serial output doCharacter() api allows char-at-a-time input to Bitlash
New Examples
Small Beans
FAQs
web serial terminal for arduino
We found that bitlash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.