Tibbo BASIC

Tibbo BASIC is a dialect of the BASIC programming language, designed for programmable logic controllers, Ethernet modules and other programmable hardware devices, both external and internal (embeddable). It is developed and distributed by Tibbo Technology Inc., a leading manufacturer of programmable Ethernet converters and controllers in Taipei, Taiwan. into intermediate-level code ("pseudo-code") and later interpreted and executed by a virtual machine for added resilience under failure.
Allowed variable types include <tt>byte, word, dword, char, short, long, real, boolean</tt> and user-defined structures and enumeration types. Objects are independent of each other and not defined in terms of classes or class hierarchies but their significance lies in treating complex low-level hardware constructs and operations as simple high-level primitives and thus greatly simplifying programming and reprogramming the device. As an example, the following code establishes a TCP connection with a target device (here assumed to have a default IP address) and sends the specified message:
<source lang="vbnet">
sub on_button_pressed
sock.connect
sock.setdata("This is a string waiting to be sent.")
sock.send
end sub
</source>
Tibbo BASIC core language can contain user-defined structures but no objects or methods.<ref name="manual"/>
Debugging of programs is done in the development environment, without a need for external in-circuit emulators, as is common with programs written in hardware description languages for embedded devices.
System components

Tibbo BASIC is part of a rapid programming framework, called TAIKO, that includes also an Integrated Development Environment and a specialized Operating System.
The Integrated Development Environment, called TIDE, contains a source code editor, a compiler and a debugger.<ref name="IDE"/>
The graphical source code editor is used to facilitate the writing of the programs;<ref name="fudz"/> Tibbo BASIC source code is saved in files with <tt>.tbs</tt> file suffix.
The compiler is used for translating the source-code from the high-lever user-friendly format into a lower-level pseudo-code
(<tt>.tpc</tt> suffix for Tibbo pseudo-code).
The debugger is used for checking that the program performs without errors. To verify this, the target hardware device is connected to the personal computer on which the program was developed, and the program is executed with different variable assignments and by triggering different combinations of possible events. While the program is running on the embedded device, its control flow and parameter settings can be observed in TIDE.
The programs on the embedded device run in a special operating system, called TiOS (Tibbo Operating System). TiOS runs two processes, the Master Process and the VM (virtual machine).<ref name="tutorial"/>
The Master Process controls communications with VM, TIDE and the events generated on the device. The VM interprets the compiled form of the program from the pseudo-code further into native binary code that the hardware processor can understand, and executes the program.
Because the VM is under the control of the Master Process, the Master Process can restart the VM (and so also the Tibbo BASIC program) if there are errors in the program that make the VM crash, and send information to TIDE about the execution state of the program during the crash for debugging and correcting.
Example code
The following example shows Tibbo BASIC code that on an embedded device that is equipped with a button and green and red LED lights, after a user presses the button, outputs "" in Morse code by the blinking of the lights. The line symbol of the Morse code is represented by a long pulse of the green light ('GGG') and the dot symbol by a short pulse of the red light ('R'). Line ('-') means that both lights are off.
<source lang="vbnet">
'===============================================================================
' HELLO WORLD IN MORSE CODE
'===============================================================================
dim hello_world as string
dim length, play_position as integer
const PAT_PLAY_CHUNK_LENGTH = 15
declare sub play_next
'--------------------------------------------------------------------
----
sub on_sys_init
hello_world =
"R-R-R-R---R---R-GGG-R-R---R-GGG-R-R---GGG-GGG-GGG" +
"-------" +
"R-GGG-GGG---GGG-GGG-GGG---R-GGG-R---R-GGG-R-R---GGG-R-R" +
"-------" +
"R-R-GGG-GGG-R-R-"
length = len(hello_world)
play_position = 0
end sub
'-------------------------------------------------------------------------------
sub on_button_pressed
play_position = 1
play_next
end sub
'-------------------------------------------------------------------------------
sub on_pat
play_next
end sub
'-------------------------------------------------------------------------------
sub play_next
if length < play_position then exit sub
dim chunk_len as integer
chunk_len = length - play_position + 1
if chunk_len > PAT_PLAY_CHUNK_LENGTH then chunk_len = PAT_PLAY_CHUNK_LENGTH
dim chunk as string
chunk = mid(hello_world, play_position, chunk_len)
pat.play(chunk, YES)
play_position = play_position + chunk_len
end sub
</source>
 
< Prev   Next >