Table of Contents

Advertisement

Quick Links

*** USER'S MANUAL ***
FCC ID : XOJGA1000

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the GA1000 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Tibbo GA1000

  • Page 1 *** USER’S MANUAL *** FCC ID : XOJGA1000...
  • Page 2 The Federal Communication Commission Statement This equipment has been tested and found to comply with the limits for a Class B Digital Device, pursuant to Part 15 of the FCC rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation.
  • Page 3: Table Of Contents

    TIDE and Tibbo BASIC User Manual Table of Contents Taiko R2 Legal Information ........................... 1 Overview Our Language Philosophy ........................... 4 System Components ........................... 7 Objects ................................8 Events ................................8 Getting Started Preparing Your Hardware ........................... 9 Starting a New Project ...........................
  • Page 4 ................................97 Byte ................................97 ByVal ................................97 Char ................................97 Else ................................97 ................................97 False ................................98 ................................98 Integer ................................98 Next ................................98 Public ................................98 Short ................................98 Step ................................98 ©2000-2008 Tibbo Technology Inc.
  • Page 5 TIDE and Tibbo BASIC User Manual String ................................98 Then ................................98 Type ................................99 ................................99 True ................................99 Word ................................99 Operators ........................... 99 Error Messages ........................... 101 C1001 ................................101 C1002 ................................101 C1003 ................................102 C1004 ................................
  • Page 6 ........................... 133 Platforms Platform Specifications ........................... 133 EM202 Platform ................................134 Memory Space ................................134 Supported Variabled Types ................................134 Supported Functions (Syscalls) ................................134 Supported Objects ................................135 Platform-dependent Constants ................................135 Enum pl_redir ................................136 ©2000-2008 Tibbo Technology Inc.
  • Page 7 TIDE and Tibbo BASIC User Manual Enum pl_io_num ................................136 Platform-dependent Programming Information ................................136 EM1000 and EM1000W Platforms ................................139 Memory Space ................................140 Supported Objects ................................140 Platform-dependent Constants ................................140 Enum pl_redir ................................141 Enum pl_io_num ................................142 Enum pl_int_num ................................
  • Page 8 ................................220 .Onsystimerperiod Property (Selected Platforms Only) ................................220 .Reboot Method ................................221 .Runmode R/O Property ................................221 Serialnum R/O Property ................................221 Setserialnum Method ................................222 .Resettype R/O Property ................................222 .Timercount R/O Property ................................223 ©2000-2008 Tibbo Technology Inc.
  • Page 9 TIDE and Tibbo BASIC User Manual .Totalbuffpages R/O Property ................................223 .Version R/O Property ................................223 Ser Object ................................224 What's new in V1.1 ................................224 Overview ................................225 Anatomy of a Serial Port ................................225 Three Modes of the Serial Port ................................
  • Page 10 HTTP-related Buffers ............................... 315 Setting the Socket for HTTP ............................... 317 Socket Behavior in the HTTP Mode ............................... 318 Including BASIC Code in HTTP Files ............................... 319 Generating Dynamic HTML Pages ............................... 320 URL Substitution ............................... 322 ©2000-2008 Tibbo Technology Inc.
  • Page 11 TIDE and Tibbo BASIC User Manual Working with HTTP Variables ............................... 323 Simple Case (Small Amout of Variable Data) ............................... 323 Complex Case (Large Amount of Variable Data) ............................... 324 Details on Variable Data ............................... 326 Properties, Methods, and Events ................................
  • Page 12 .Getdata Method (previously .Get) ................................381 .Setdata Method (previously .Set) ................................382 .Size R/O Property ................................383 Pat Object ................................384 .Channel Property ................................385 .Greenmap Property ................................385 On_pat Event ................................386 .Play Method ................................386 ©2000-2008 Tibbo Technology Inc.
  • Page 13 TIDE and Tibbo BASIC User Manual .Redmap Property ................................387 Beep Object ................................387 .Divider Property ................................388 On_beep Event ................................388 .Play Method ................................389 RTC Object ................................389 .Getdata Method (Previously .Get) ................................390 .Running R/O Property ................................391 .Setdata Method (Previously .Set)
  • Page 14 .Maxstoredfiles R/O Property ................................474 .Mount Method ................................474 .Numservicesectors R/O Property ................................475 .Open Method ................................475 .Pointer R/O Property ................................476 .Ready R/O Property ................................476 .Rename Method ................................477 .Resetdirpointer Method ................................478 ©2000-2008 Tibbo Technology Inc.
  • Page 15 XIII TIDE and Tibbo BASIC User Manual .Sector R/O Property ................................478 .Setattributes Method ................................478 .Setbuffer Method ................................479 .Setdata Method ................................480 .Setfilesize Method ................................481 .Setpointer Method ................................482 .Setsector Method ................................483 .Totalsize R/O Property ................................483 Kp Object ................................
  • Page 16 ................................527 .Ssid Property ................................528 .Task R/O Property ................................528 .Wepkey1 Property ................................529 .Wepkey2 Property ................................529 .Wepkey3 Property ................................529 .Wepkey4 Property ................................529 .Wepmode Property ................................530 Update History (for this Manual) ©2000-2008 Tibbo Technology Inc.
  • Page 17: Taiko R2

    BASIC you might already know), using a PC software called TIDE - Tibbo Integrated Development Environment. Your program is then compiled into a binary file and uploaded onto a Tibbo module. The Virtual Machine of TiOS then executes this binary.
  • Page 18 (your Company) wish to make use of any documentation or technical information published by TIBBO, and/or make use of any source code published by TIBBO, and/or consult TIBBO and receive technical support from TIBBO or any of its employees acting in an official or unofficial capacity, You must acknowledge and accept the following disclaimers: 1.
  • Page 19 Tibbo staff (in an official capacity or otherwise) or content published by TIBBO or any other third party.
  • Page 20: Overview

     Events  Our Language Philosophy Several principles have guided us through the development process of Tibbo Basic. Understanding them would help you understand this manual better, and also the language itself. See below: A Bit of History Years ago, programming for the PC was the nearly exclusive domain of engineers.
  • Page 21 Internet or controlling motors and sensors. Ideally, Tibbo Basic could run on a fridge just as well as it could run on a time and attendance terminal. Principle Four: Thin and Agile A lot of embedded systems are built by scaling down larger desktop systems, and it shows.
  • Page 22 They execute from top to bottom. This may be called linear execution. For Tibbo Basic, this is not the case. The programs you will write will be event- driven. Your program will consist of a number of event handlers which will be fired (invoked) in response to specific things which happen to your system in real life.
  • Page 23: System Components

    The compiler is a utility program, used by TIDE. The compiler processes your project files and creates an executable binary file (with a .tpc suffix, for Tibbo PCode). The target is a separate hardware device, on which your program actually runs.
  • Page 24: Objects

    A platform can be described as a collection of objects. Under Tibbo Basic, the set of object you get for each platform is fixed. You cannot add new objects or create multiple instances of the same object.
  • Page 25: Getting Started

    UDP messages. This is essential for communications between TIDE and the DS202 while debugging.  Run Device Explorer (Start > Programs > Tibbo > Tibbo IDE > Device Explorer).  You should see your device on the list. Select it.
  • Page 26: Starting A New Project

    Project name: Type 'Hello World'. Location: Leave untouched, unless you have a good reason to change it. Transport: leave it as is ("Taiko UDP Broadcast Transport") Target Address: Click Browse. You will be presented with the following dialog: ©2000-2008 Tibbo Technology Inc.
  • Page 27: Writing Code

    TIDE and Tibbo BASIC User Manual The number (hopefully) displayed is the MAC address of your target. If you select it and click Buzz, you should see the LED pattern on your target switch off momentarily. This means it is correctly detected.
  • Page 28 First, we want the pattern to start playing whenever you press the button. For this, our platform offers a button object, which generates an on_button_pressed event. Instead of typing, you can create the event handler for this event by double- clicking on the event name in the project tree ©2000-2008 Tibbo Technology Inc.
  • Page 29 TIDE and Tibbo BASIC User Manual on_button_pressed ' event handler fired whenever the button is pressed play_position = ' start playing from the beginning of the pattern play_next ' call the routine which plays the next chunk (the first chunk, in this case) end sub Notice that the play_next routine is not yet defined.
  • Page 30: Building, Uploading And Running

    Once you are done with writing your project, it is time to build, upload and run it. These three operations can be done by pressing F5. Press F5 and wait. You will see your project compiling. The output pane will ©2000-2008 Tibbo Technology Inc.
  • Page 31: Compiling A Final Binary

    The topics below attempt to give you a general understanding about working with Tibbo Basic. An attempt has been made to lay them out as logically as possible; it would be advised to just read them from top to bottom and follow the links every time you don't understand a term.
  • Page 32 HTML files: Multiple files with an .html extension (displayed with the currently associated icon). Contain webpages to be displayed by the embedded webserver. These can include blocks of Tibbo Basic code. See Working with HTML (Any Resource files: Multiple files without any set extension.
  • Page 33: Creating, Opening And Saving Projects

    TIDE and Tibbo BASIC User Manual Creating, Opening and Saving Projects To create a new project, select File > New. The following dialog will appear: Platform: The platform on which your project will run. Available project types: Various quick-start templates .
  • Page 34: Adding, Removing And Saving Files

    . It looks like this: Adding New Files to Your Project To add new files to your project, click Project > Add File or click the Add button on the Project Toolbar. You will be presented with the following dialog: ©2000-2008 Tibbo Technology Inc.
  • Page 35 TIDE and Tibbo BASIC User Manual Specify a name for your file under Filename. If you also specify an extension, the Add as listbox is automatically updated. Automatically recognized file types are:  .tbs -- basic files  .h -- header files ...
  • Page 36: Resource Files

    Tibbo Basic compiler but simply used as-is within the project. These files are not modified or compressed in any way; they are merely included...
  • Page 37 TIDE and Tibbo BASIC User Manual ... or RGB color selector: Double-clicking on the image file with .bmp, .jpg, .png, or .gif extension opens the image editor. All image-related editing functionality is concentrated within Image menu ...and Image Editor toolbar...
  • Page 38: Coding Your Project

    The icon becomes "active" when the event handler is created. An icon next to a procedure is grayed if this procedure is merely declared but does not yet have a body. The icon becomes active once the ©2000-2008 Tibbo Technology Inc.
  • Page 39: Code Auto-Completion

    TIDE and Tibbo BASIC User Manual procedure is implemented ("gets" a body). Same applies to global variables -- gray icon next to variables that are declared but not yet defined, active icon for defined global variables. Double-clicking on an event which does not yet have an event handler will create an empty event handler procedure for this event at the bottom of the currently active file.
  • Page 40: Code Hinting

    "ser.enabled=" you will get a list of possible values of this property: By pressing Alt+Ctrl+T when the cursor is directly to the right of any meaningful Tibbo Basic construct, you will get a pop-up list with the appropriate contents for the current context. If the cursor isn't...
  • Page 41 TIDE and Tibbo BASIC User Manual In the code editor, you may also display a tooltip with the keyboard by pressing Ctrl+T when the cursor is within an event handler, a procedure, a constant or a global variable. Tooltip text for properties, methods, and events comes from the platform file for platform selected in your project.
  • Page 42: Supported Html Tags

    Project > Rebuild All. On build, the Output pane will display any errors. You can double-click on the line describing an error to jump directly to the problematic line in your code. Uploading a Binary ©2000-2008 Tibbo Technology Inc.
  • Page 43: Two Modes Of Target Execution

    TIDE and Tibbo BASIC User Manual To upload your project, you must select Project > Upload or click the Upload button on the Debug toolbar. Before uploading, TIDE checks if the project has been changed since it was last built. If so, it builds the project again and attempts to upload the new build.
  • Page 44: Debugging Your Project

    (a yellow line) is displayed and indicates the next instruction that the Virtual Machine will execute when started. You can now inspect and change various properties and variables (both global and local) using the watch . This is the only state which allows stepping ©2000-2008 Tibbo Technology Inc.
  • Page 45: Exceptions

    TIDE and Tibbo BASIC User Manual Pause: This message occurs when the Virtual Machine on the target was stopped while not executing code (in other words, it was caught between events). No program pointer is displayed in this state, because no code is being executed.
  • Page 46: Program Pointer

    Floating point error Invalid opcode* Access outside of user memory* Failed to load binary library* *This exception indicates that either TiOS or Tibbo Basic compiler is not functioning properly. Let us know if you encounter this exception! Program Pointer 4.1.8.2 The program pointer is a line, highlighted in yellow, which shows the present location of program execution.
  • Page 47: The Call Stack And Stack Pointer

    TIDE and Tibbo BASIC User Manual The yellow arrow over the red dot merely marks the program pointer; a breakpoint is always marked by a red dot. Where a Breakpoint May Be Placed A breakpoint may be placed only on a line which contains executable code; before compiling your project, you could place breakpoints anywhere.
  • Page 48: Stepping

    (the program pointer). Any sort of stepping would bring back the yellow program pointer, both in the source code and in the call stack. Stepping 4.1.8.5 The following commands in the Debug menu control stepping into, through and out of various sections of your code: ©2000-2008 Tibbo Technology Inc.
  • Page 49: The Watch

    TIDE and Tibbo BASIC User Manual A step is an instruction to move the program pointer to another line in source code. Stepping allows you to execute your code in a very controlled way, and work your way along the program in a pace which you can analyze and understand.
  • Page 50 In the Add to Watch List dialog you may type multiple items to be added to the watch by separating their names with commas (i.e. "i, j, k, ser.num"). For objects you will get a drop-down list of available members: ©2000-2008 Tibbo Technology Inc.
  • Page 51 TIDE and Tibbo BASIC User Manual Double-clicking the Name column in the watch pane will allow you to edit the name of the item you want to watch. The watch pane also allows you to change the value of any variable or object property (provided it is not a read-only property).
  • Page 52 This is one of the main reasons for the existence of enumeration types in Tibbo Basic. To remove a variable from the watch, select it and press Delete, select Debug >...
  • Page 53: Scopes In Watch

    TIDE and Tibbo BASIC User Manual Scopes in Watch The watch facility is only active when the Virtual Machine is not running, i.e. the execution is stopped. Naturally, the TIDE cannot fetch variable values while the Virtual Machine is executing your program.
  • Page 54: Project Settings

    TIDE and target -- TCP/IP, serial, etc. Thus, their target address may not always be a MAC address. This goes for the browse button as well -- not all platforms have this button. ©2000-2008 Tibbo Technology Inc.
  • Page 55: Programming Fundamentals

    Programming Fundamentals This chapter attempts to provide a very quick run through the fundamentals of creating a program in Tibbo Basic. It was written under the assumption that the reader has some experience in programming for other languages. There is a marked resemblance between Tibbo Basic and other types of BASIC that you may already know.
  • Page 56: Code Basics

    Programming with TIDE platform. If your Tibbo Basic program runs on a refrigerator, you would probably have an event handler for the door opening. on_door_open light = 1 ' turn on the light when someone opens the door to your fridge.
  • Page 57 ' is just like y=x+5 ' and even this is OK: So, spaces, tabs and linefeeds carry no special meaning in Tibbo Basic. Use them or lose them, as you like. The only exceptions are the If..Then... Else Statement and comments.
  • Page 58: Naming Conventions

    How to Use Colons Colons are actually not necessary in most parts of Tibbo Basic. They are a traditional part of many BASIC implementations, and are often used to group several statements in one line. However, since Tibbo Basic doesn't really care about spaces anyway, they lose their relevance.
  • Page 59: Introduction To Variables, Constants And Scopes

    ' event names may contain more than one word after the object name. Introduction to Variables, Constants and Scopes Variables and constants are a major part of any programming language, and Tibbo Basic is no exception; below you will find explanations on the following: Variables And Their Types ...
  • Page 60 ' x is now equal to y. str = "foobar" ' str now contains the string 'foobar' (with no quotes). Types of Variables Tibbo Basic supports the following variable types: Name Description byte Hardware-level. Unsigned. Takes 1 byte in memory. Can hold integer numerical values from 0 to 255 (&hFF).
  • Page 61: Type Conversion

    TIDE and Tibbo BASIC User Manual string Hardware-level. Takes up to 257 bytes in memory (max string size can be defined separately for each string variable). Strings can actually be up to 255 bytes long but always begin with a 2-byte header -- 1 byte specifies current length, and 1 byte specifies maximum length.
  • Page 62 "side". As an example, see this conversion from byte into char: as byte as char c = x ' c now contains the binary value of 254, which is interpreted as -2 ©2000-2008 Tibbo Technology Inc.
  • Page 63 TIDE and Tibbo BASIC User Manual In the above example, both x and c will contain the same binary data. However, c is a signed 8-bit value, so binary contents of 254 mean -2. Strictly speaking, this reinterpretation will only happen if the value of x exceeds maximum positive number that c can hold -- 127.
  • Page 64: Type Conversion In Expressions

    Mixing in a 32-variable will cause the compiler to use 32-bit calculations For the example above, turn i or j into a dword. Now, your calculations will be correct. Mixing in any 32-bit variable will aotumatically upgrade calculations to 32 bits! ©2000-2008 Tibbo Technology Inc.
  • Page 65: Compile-Time Calculations

    Compile-time Calculations 4.2.4.4 Tibbo Basic always tries to pre-calculate everything that can be pre-calculated during compilation. For example, if you write the following code: as byte x=5+10+y...
  • Page 66: Arrays

    Each element has a value and an index number, and may be accessed using this number. An example of a simple array would be: Index: Value: The code to produce such an array in Tibbo Basic would look like this: x(5) as char x(0) = x(1) =...
  • Page 67 TIDE and Tibbo BASIC User Manual variable. y = x(4) ' y would get a value of -30, according to the previous array y = x(z) ' y would get the value of index z within array x. As an example, you could iterate through an array with a loop (such as a For...
  • Page 68 Iterating through such an array would be done using a nested loop for each dimension in the array. The array above contains only two dimensions, so we would nest one loop within another. For an array containing six dimensions, we would have to use six such nested loops. See: ©2000-2008 Tibbo Technology Inc.
  • Page 69 ' here, sum would be equal to the sum of the whole array. How much is that? Try and see. In Tibbo Basic, you may define up to 8 dimensions in an array. Alternative way of defining arrays We have already explained that the following string means "an array x containing 10 elements of type byte":...
  • Page 70: Structures

    After that, you can address individual elements of the structure as follows: var1.x=5 var1.y=12345678 var1.s="Test" Structures you define may include members that are arrays or other structures. Structure variables like var1 above can be arrays as well, of course. In total, Tibbo ©2000-2008 Tibbo Technology Inc.
  • Page 71: Enumeration Types

    TIDE and Tibbo BASIC User Manual Basic supports up to eight nesting levels (as in "array within a structure within a structure within and array" -- each structure or array is one level and up to 8 levels are possible). Here is a complex example:...
  • Page 72 -32768 to 32767 short 0 to 65535 word -2147483648 to 2147483647 long 0 to 4294967295 dword Notice, that enumeration types cannot be converted into real values, so you cannot use fractional numbers in you enums. Some examples: ©2000-2008 Tibbo Technology Inc.
  • Page 73: Understanding The Scope Of Variables

    TIDE and Tibbo BASIC User Manual enum tiny tinyfoo, tinybar end enum ' this enum will be associated with a char type enum medium mediumfoo = mediumbar end enum ' this enum will be associated with a byte type enum...
  • Page 74 5. only this local x equals 30. next end sub Tibbo Basic supports several scopes: Global Scope Every compilation unit has, in itself, one global scope. Variables declared in this scope are accessible from within any sub or function in this compilation unit.
  • Page 75 HTML Scope This section applies only to platforms which include an HTTP server. This is a special scope, implemented in Tibbo Basic. HTML files included within a project may contain embedded Tibbo Basic code. This code is executed when the HTTP server processes an HTTP GET (or POST) request.
  • Page 76: Declaring Variables

    Constants are used to represent values which do not change throughout the program; these values may be strings or numbers. They may either be stated explicitly, or be derived as the result of an expression. Some examples: ©2000-2008 Tibbo Technology Inc.
  • Page 77 BASIC language. The only way to do so was like this: s = "abc"+chr(10)+chr(13) 'add LF/CR in the end In Tibbo Basic you can achieve the same by using escape sequences -- C style: s = "abc\n\f" ''\n' means LF, '\f' -- CR const STR1 = "abc\x10\x13"...
  • Page 78: Introduction To Procedures

    "\x0A" -- leading zero must not be omitted. Introduction to Procedures A procedure is a named piece of code, which performs a designated task, and can be called (used) by other parts of the program. In Tibbo Basic, there are two types of procedures: Function Procedures...
  • Page 79 TIDE and Tibbo BASIC User Manual a(10) as byte ' a is a global variable -- outside the scope of the function. init_array as integer a(i) = ' the global variable gets changed. next end sub Subs change the value of the arguments passed to them using...
  • Page 80: Passing Arguments To Procedures

    ' at this point in code, y is still 2. end sub This way of passing variables is the default used in Tibbo Basic. Passing By Reference In certain cases, copying is not the preferred solution; for example, when a procedure has to modify several arguments passed to it and these later have to be ©2000-2008 Tibbo Technology Inc.
  • Page 81 Strict byref argument match is now required! Beginning with Tibbo Basic release 2.0, strict match is required between the type of byref argument and the type of variable being passed. For example, trying to...
  • Page 82: Memory Allocation For Procedures

    B has completed. Thus, the total memory required for this tree is 11 bytes. Now, let us say we also have on_event_2 in our project, which calls procedure C, which in turn calls procedure D. This is a completely separate chain: ©2000-2008 Tibbo Technology Inc.
  • Page 83: Introduction To Control Structures

    TIDE and Tibbo BASIC User Manual As can be seen, this chain takes up 7 bytes of memory. However, this memory can be the same memory used for the on_event_1 chain, because these two chains will never execute at the same time. Thus, the total memory required for our project remains at 11 bytes.
  • Page 84: Loop Structures

    Doevents 4.2.6.3 Although under Tibbo Basic, event-driven programming is the norm, there may be special cases in which you just have to linger an overly long time in one event handler. This will block execution of other events. They will just keep accumulating...
  • Page 85 TIDE and Tibbo BASIC User Manual 'calculate sum of all array elements -- this will surely take time! sum, f as word sum = 49999 sum = sum + arr(f) doevents 'don't want to stall other events so allow their execution...
  • Page 86 A still holds variables in memory, waiting for control to return to it. This would corrupt the values of variables used by the first A (if you try to do something like this, the compiler will raise an error). ©2000-2008 Tibbo Technology Inc.
  • Page 87: Using Preprocessor

    Otherwise, we would once again get recursion (execution of an event handler while a previous instance of this event handler is already executing), which is not allowed under Tibbo Basic. Using Preprocessor Tibbo Basic compiler includes a preprocessor that understands several directives.
  • Page 88 Do not confuse compile-time definitions such as "#define OPTION 2" and actual application code like "const COLOR=2" or "x=3". They are from two different worlds and you can't use the latter as part of #if directives. For example, the following will not work: ©2000-2008 Tibbo Technology Inc.
  • Page 89: Scope Of Preprocessor Directives

    TIDE and Tibbo BASIC User Manual #define OPTION 0 'preprocessor directive Const COLOR=2 'constant used by your application OPTION=COLOR 'to a confused programmer, this looks like 0=2, but COLOR is not #defined, hence, it will be evaluated to 0 'hence, this code will be compiled in!
  • Page 90: Working With Html

    TCP communications). You can use this webserver as an engine for server-side scripting; simply put, you can output dynamic HTML content by including Tibbo Basic instructions within HTML pages.
  • Page 91 They would just have to enter an address in a web browser, and voila, up comes your interface. HTML support, as implemented in the Tibbo Basic, allows you complete control over page structure. You can use client-side technologies such as JavaScript, CSS etc., while still being able to dynamically generate HTML content within Tibbo...
  • Page 92: Embedding Code Within An Html File

    To begin a block of Tibbo Basic code within an HTML file, you must use an escape sequence -- <? . To close the section of code, use the reverse escape sequence -- ?>...
  • Page 93: Understanding Platforms

    This holds true even for string functions -- some platforms are so tiny, they do not even need to support string processing! Because of this, the 'core' of the Tibbo Basic language is actually very minimalistic -- we call it "pure" -- it contains only the statements listed under Statements below.
  • Page 94: Objects, Events And Platform Functions

    Platform Functions Many functions commonly available in other BASIC versions are implemented in Tibbo Basic on the platform level and not on the "pure" language level; these include also seemingly universal functions, such as string processing, or various date and time functions. This is done so because not every platform would actually need these functions, universal as they may seem.
  • Page 95: Statements

    You could say they are the programming-language equivalent of a sentence in human speech. Statements are built into Tibbo Basic itself, and are not platform-specific. Const Statement Function: Declares constants for use in place of literal values.
  • Page 96 (see Dim Statement Usually, variables and functions which are shared between compilation units are declared in a header file, and this header is then included in the units (see Include Statement ©2000-2008 Tibbo Technology Inc.
  • Page 97: Dim Statement

    TIDE and Tibbo BASIC User Manual Example declare function hittest(x integer, y integer) as boolean declare sub dosomething (s as byref string) declare devicestate as integer Dim Statement Function: Defines a variable and allocates memory for it. [ public ] dim name1 [ (bounds1) ] [ , name2 [...
  • Page 98: Doevents Statement

    'don't want to stall other events so allow their execution while we are crunching numbers next Do... Loop Statement Repeats a block of statements while a condition is True Function: or until a condition becomes True. ©2000-2008 Tibbo Technology Inc.
  • Page 99 TIDE and Tibbo BASIC User Manual do [ while | until ] expression Syntax: statement1 statement2 … [exit do] statementN loop statement1 statement2 … [exit do] statementN loop [ while | until ] expression Scope: Local and HTML See Also: For...
  • Page 100: Enum Statement

    Description name Required. The name of the enum type. The name must be a valid Tibbo Basic identifier, and is specified as the type when declaring variables or parameters of the enum type. const[1, 2...] Required. The name for the constant in the enum.
  • Page 101: Exit Statement

    TIDE and Tibbo BASIC User Manual Exit Statement Function: Immediately terminates execution of function or a loop. exit do Syntax: exit for exit function exit sub exit while Scope: Local and HTML See Also: Do-Loop Statement For... Next Statement Function...
  • Page 102: For

    There is also an exit statement which can be used to terminate them abruptly. Under Tibbo Basic, you are required to explicitly state the name of the cycle variable to be incremented immediately following the next keyword. Examples ©2000-2008 Tibbo Technology Inc.
  • Page 103: Function Statement

    TIDE and Tibbo BASIC User Manual a(10) as integer as byte f = 0 ' in a 10-member array, element indices are 0 to 9 sum = sum + a(f) next Function Statement Used to define functions -- distinct units in code which Function: perform specific tasks and always return a value.
  • Page 104: Goto Statement

    Required. Marks a specific point in code. Details Unconditionally jumps to label in code. Notice that all goto labels are local -- you cannot use goto statement to jump from within one procedure into another procedure! Examples ©2000-2008 Tibbo Technology Inc.
  • Page 105: If.... Then... Else Statement

    TIDE and Tibbo BASIC User Manual arr1(5),arr2(5),f as byte on_sys_init arr1(0) = arr1(1) = arr1(2) = arr1(3) = arr1(4) = arr2(0) = arr2(1) = arr2(2) = arr2(3) = arr2(4) = 'compare arrays and jump if not exactly the same arr1(f)<>arr2(f)
  • Page 106: Include Statement

    This is the only construct under Tibbo Basic where line end matters. So, if you want to have several statements in such a construct, you need to place them all in the same line, and separate them with colons.
  • Page 107: Select-Case Statement

    TIDE and Tibbo BASIC User Manual "filename" Contains the filename to be included. The path can be a relative path to the project path , an absolute path (such as c:\myfolder\myfile.tbs) or even a UNC path (such as \\MY-SERVER\Main\myfile.tbs). Details Makes compiler include the contents of a file at the point of the include statement.
  • Page 108 Also, remember that writing two select_expressions at the same time does not mean that there will be a shared code for both of them. Rather, it means that the first expression will have no code associated with it! ©2000-2008 Tibbo Technology Inc.
  • Page 109: Sub Statement

    TIDE and Tibbo BASIC User Manual case 'this expression has no code associated with it case 'code 'x=5' belongs to this expression Correct way to have a single block of code for two expressions is as follows: case 1,2 :...
  • Page 110: Type Statement

    Syntax: name1 [ (bounds1) ] as type [ (max_string_size) ] nameN [ (boundsN) ] as type [ (max_string_size) ] end type Scope: Global, HTML and local See Also: Dim Statement Part Description ©2000-2008 Tibbo Technology Inc.
  • Page 111: While-Wend Statement

    TIDE and Tibbo BASIC User Manual type_name Required. Specifies the name for this structure type (not a particular variable). name[1, 2...] Required. Specifies the name for the member variable. bounds[1, 2...] Optional. Specifies the boundary (finite size) of a dimension in an array.
  • Page 112: Keywords

    This chapter contains links from single keywords to the statements in which you may find them. It is meant to be used as a resource for context-sensitive help. A keyword designating data type. Appears as part of the following statements: Declare Statement Dim Statement Function Statement Sub Statement ©2000-2008 Tibbo Technology Inc.
  • Page 113: Boolean

    TIDE and Tibbo BASIC User Manual Boolean A data type. Please see Variables And Their Types ByRef A keyword designating a way of passing arguments. Appears as part of the following statements: Function Statement Sub Statement For further details, see...
  • Page 114: False

    Appears as part of the following statement: For... Next Statement String A data type. Please see Variables And Their Types Then A keyword used to denote conditional execution. Appears as part of the following statement: If..Then... Else Statement ©2000-2008 Tibbo Technology Inc.
  • Page 115: Type

    TIDE and Tibbo BASIC User Manual Type Appears as part of the following statement: Type Statement Appears as part of the following statement: For... Next Statement True A byte constant with a value of 1, associated with boolean variables. Word A data type.
  • Page 116 = NOT &b01011001 ' this would be &b10100110 OR Operator (1) Logical OR. (2) Bitwise OR. if i = 5 OR j = 10 then..' as a logical OR &b10110101 OR &b01011001 ' this would be &b11111101 ©2000-2008 Tibbo Technology Inc.
  • Page 117: Error Messages

    &b11101100 Error Messages Below is a listing of all error messages which may appear when trying to build and upload your Tibbo BASIC program onto a target. C1001 Description: This error occurs when a source file contains an “illegal” character (like a special character, a non-English letter, etc) outside of a string literal or a comment.
  • Page 118: C1003

    The compiler detected an attempt to specify a numerical constant using an incorrect format. Example: x = &G12 ' error C1005: invalid numeric constant: unknown base 'G' &b102 ' error C1005: invalid numeric constant ' error C1005: invalid numeric constant See Also Type Conversion  ©2000-2008 Tibbo Technology Inc.
  • Page 119: C1006

    TIDE and Tibbo BASIC User Manual C1006 Description: This error occurs when Tibbo BASIC syntax is violated. Refer to the documentation of a particular statement to see its syntax. Example: select x ‘ error C1006: 'Case' expected case case true...
  • Page 120: C1008

    (of an enumeration type, a constant, a variable or a function). Example: as string ' error C1010: redefinition of identifier 'x' … end sub See Also ©2000-2008 Tibbo Technology Inc.
  • Page 121: C1011

    TIDE and Tibbo BASIC User Manual Identifier  C1011 Description: This error occurs when attempting to define a procedure twice. Example: end sub ' error C1011: 'x' already has body end sub See Also Sub Statement  Function Statement ...
  • Page 122: C1013

    ' error C1014: 'x' is not a label See Also Identifier  C1015 Description: The next clause of a for/next statement must use the same index variable as the for clause. Example: as integer next ' error C1015: 'For'/'Next' arguments mismatch ©2000-2008 Tibbo Technology Inc.
  • Page 123: C1016

    TIDE and Tibbo BASIC User Manual See Also For... Next Statement  C1016 Description: The exit statement may be used only from within certain statements (for, while, do-loop, sub, function). This error occurs when the compiler encounters an exit statement which is used not from within one of these statements.
  • Page 124: C1019

    8 dimensions are allowed). Example: i(2,2,2,2,2,2,2,2,2) as integer ' error C1020: Too many array dimensions (8 max) See Also Arrays  C1021 Description: This error occurs when a property was defined for read-only or for write-only, but ©2000-2008 Tibbo Technology Inc.
  • Page 125: C1022

    TIDE and Tibbo BASIC User Manual the program tries to access this property in a different way. Example: sys.runmode = PL_SYS_MODE_DEBUG ' error C1021: write access to property is denied See Also Understanding Platforms  C1022 Description: There are several system calls which the compiler uses directly, and are invoked implicitly in code (string comparison, string copy, conversion from string to number, etc).
  • Page 126: C1024

    This error occurs when the linker attempts to link two object files with different counts of platform event handlers. Most commonly this error means that you are trying to link object files built for two different platforms. See Also System Components  ©2000-2008 Tibbo Technology Inc.
  • Page 127: L1003

    TIDE and Tibbo BASIC User Manual L1003 Description: During linking, one or more addresses remained unresolved. That means that these addresses are referenced from one or more compilation units but are never defined. See Also Declare Statement  L1004 Description:...
  • Page 128: L1007

    See Also Platform Specifications  L1009 Description: The amount of FLASH (program memory) needed to store your project exceeds the maximum possible size for this platform. I.e, your program is too large. See Also Platform Specifications  ©2000-2008 Tibbo Technology Inc.
  • Page 129: Objects, Properties, Methods, Events

    TIDE and Tibbo BASIC User Manual Objects, Properties, Methods, Events Under Tibbo Basic, these are all platform-specific constructs. Please refer to your Platform documentation for details about the objects, properties, methods and events for your platform. Development Environment Below is an overview of the TIDE GUI.
  • Page 130: Main Window

    Debug Mode and hide it while in Edit Mode. Every time you will go into Debug Mode, the toolbar would appear. When you switch back to the Edit Mode, the toolbar will disappear. Thus, you may customize ©2000-2008 Tibbo Technology Inc.
  • Page 131: Menu Bar

    TIDE and Tibbo BASIC User Manual your workspace so it would serve you best both while editing code and while debugging. Another key difference is that while in Debug Mode you cannot enter any new code. Whenever you try to type code while in this mode, you will be prompted to stop program execution on the target and switch back to Edit Mode.
  • Page 132: Edit Menu

    Edit Menu 6.2.3.2 Undo: Cancels last action. Redo: Cancels last undo. Cut, Copy, Paste: Standard edit actions. Select All: Select all text. Find, Find Next, Find Prev, Find in Files, Replace: Standard find & replace actions. ©2000-2008 Tibbo Technology Inc.
  • Page 133: View Menu

    TIDE and Tibbo BASIC User Manual View Menu 6.2.3.3 Project Toolbar: Toggles (shows/hides) the Project toolbar. Debug Toolbar: Toggles the Debug toolbar. Status Bar: Toggles the Status Bar Project: Toggles the Project pane. Output: Toggles the Output pane. Clear Output: Clears the contents of the Output pane.
  • Page 134: Debug Menu

    Jump to Cursor: Covered under Stepping above. Toggle Breakpoint: Covered under Breakpoints above. Remove All Breakpoints: Covered under Breakpoints above. Add to Watch List: Covered under The Watch above. Remove from Watch List: Covered under The Watch above. ©2000-2008 Tibbo Technology Inc.
  • Page 135: Image Menu

    TIDE and Tibbo BASIC User Manual Image Menu 6.2.3.6 This menu is visible only when a graphical resource is selected for editing. TIDE "knows" how to work with .bmp, .jpg, .gif, and .png files. Resize: Changes the size of the image's "canvas". This is not re-sampling of the image: existing image elements won't shrink or get larger, just the total image size in pixels will change.
  • Page 136: Help Menu

    Save Project: Saves all modified files on this project. Happens automatically on build. Add File: Displays the Add file to project dialog. Remove File: Removes current file from project. Does not delete file from disk. Settings: Displays the Project Settings dialog. Copy: Self-explanatory. ©2000-2008 Tibbo Technology Inc.
  • Page 137: Debug Toolbar

    TIDE and Tibbo BASIC User Manual Cut: Self-explanatory. Paste: Self-explanatory. Undo: Cancels last action. Redo: Cancels last undo. Find: Self-explanatory. Find Next: Self-explanatory. Find Prev: Self-explanatory. Replace: Self-explanatory. Debug Toolbar 6.2.4.2 Select/Manage Target: Shows the platform-specific dialog used to select a target for your project and upload firmware.
  • Page 138: Image Editor Toolbar

    The following toolbars are available: Selection Tool Properties Toolbar  Paint Tool Properties Toolbar  Eraser Tool Properties Toolbar  Text Tool Properties Toolbar  Line Tool Properties Toolbar  Rectangle Tool Properties Toolbar  ©2000-2008 Tibbo Technology Inc.
  • Page 139: Selection Tool Properties

    TIDE and Tibbo BASIC User Manual Ellipse Tool Properties Toolbar  Zoom Tool Properties Toolbar  Selection Tool Properties Transparency Mode: For drag/drop and copy/paste operations selects whether pixels of background color will be copied to the destination as well. When the transparency mode is OFF the rectangular image fragment being copied or moved will overlay original image underneath completely.
  • Page 140: Line Tool Properties

    When inversion is ON, the line will appear in fore-ground color over the areas originally painted in background color and in background color over the areas originally painted with non-background color. Size: Line width in pixels. Rectangle Tool Properties ©2000-2008 Tibbo Technology Inc.
  • Page 141: Ellipse Tool Properties

    TIDE and Tibbo BASIC User Manual Inversion Mode: Toggles rectangle tool's inversion mode on/off. When inversion is OFF, the rectangle's border will always be drawn in the fore-ground color and filling (for filled rectangles) will always be done with background color. When...
  • Page 142: Zoom Tool Properties

    Num Lock and Scroll Lock. Dialogs Not all dialogs are reviewed -- only the ones which are not self-explanatory. In this section: Project Settings  New Project  Add file to Project  Graphic File Properties Dialog  ©2000-2008 Tibbo Technology Inc.
  • Page 143: Project Settings

    TIDE and Tibbo BASIC User Manual Project Settings 6.2.6.1 This dialog has been covered under Project Settings above. New Project 6.2.6.2 This dialog has been covered under Starting a New Project above. ©2000-2008 Tibbo Technology Inc.
  • Page 144: Add File To Project

    Some panes may be toggled using shortcut keys or the View Menu Colors pane is displayed automatically when an image resource file is opened for editing. In this section: Call Stack  Output  Project  Watch  Colors  Call Stack 6.2.7.1 ©2000-2008 Tibbo Technology Inc.
  • Page 145: Output

    TIDE and Tibbo BASIC User Manual The Call Stack pane is covered under The Call Stack above. Output 6.2.7.2 Displays status messages while compiling, linking, uploading and debugging. Double clicking on an error message would move the cursor to the line of code which caused the error.
  • Page 146: Files

    Colors pane is displayed whenever a graphical resource is opened for editing in TIDE. Depending on the color mode selection you've made when adding an image file to the project, the pane will either show available palette colors..or RGB color selector: ©2000-2008 Tibbo Technology Inc.
  • Page 147: Language Element Icons

    TIDE and Tibbo BASIC User Manual Language Element Icons Throughout TIDE, many icons are used for various Tibbo Basic constructs. Below is a complete listing: Constants (see Constants Enumeration Types (see User-Defined Types System Calls (see Function Reference Objects (see...
  • Page 148: Construct

    This is the practice of using one device to observe and control the state of a program running on another device, in order to find bugs in it. Under Tibbo Basic, your computer displays various status messages and information about variables...
  • Page 149: Target

    TIDE and Tibbo BASIC User Manual Target The hardware device with which you are working. This is the device connected to the computer while debugging. The code you are writing actually runs on this device, and the debug messages originate from the device -- not from anywhere within your computer.
  • Page 150: Em202 Platform

    For general type description see Variables and Their Types Supported Functions (Syscalls) 8.1.1.3 The following syscalls (platform functions) are supported by the platform:  Conversion to and from strings: string character --> ASCII code; ASCII code --> string character; ©2000-2008 Tibbo Technology Inc.
  • Page 151: Supported Objects

    TIDE and Tibbo BASIC User Manual numerical string--> 16-bit value (word or short); unsigned 16-bit numeric value (word) --> binary numerical string; unsigned 16-bit numeric value (word) --> decimal numerical string; Stri signed 16-bit numeric value (short) --> decimal numerical string;...
  • Page 152: Enum Pl_Io_Num

    This section contains miscellaneous information that sets this platform apart from other platforms. Various objects described in the Object Reference direct you to this topic in all cases when object capabilities or behavior depends on the platform ©2000-2008 Tibbo Technology Inc.
  • Page 153 TIDE and Tibbo BASIC User Manual and, hence, cannot be described in the object reference itself. Each platform section in this manual has its own "Platform-dependent Programming Information" topic. If you are reading documentation top-to-bottom (we have never actually met anyone who does) you can skip this section now.
  • Page 154 8 stores the checksum, which is calculated like this: 255-(modulo8_sum_of_addr_1_through_7) Here is a sample code that stores new MAC address into the EEPROM and then reboots the device to make the device load this new MAC: ©2000-2008 Tibbo Technology Inc.
  • Page 155: Em1000 And Em1000W Platforms

    The difference between the EM1000 and EM1000W platforms is that the EM1000W additionally includes the (Wi-Fi) object, which works with an external GA1000 add-on module to function. All other features of these two platforms are exactly the same. Both platforms will be collectively referred to as "EM1000(W)". Memory Space ...
  • Page 156: Memory Space

     — handles Wi-Fi interface (only available on the EM1000W platform,  requires GA1000 add-on module); — in charge of serial ports (UART, Wiegand, and clock/data modes);  — handles I/O lines, ports, and interrupts;  — controls graphical display panels (several types supported);...
  • Page 157: Enum Pl_Redir

    TIDE and Tibbo BASIC User Manual Enum pl_int_num - a list of constants that define available interrupt lines.  Enum pl_sock_interfaces - a list of available network interfaces.  Enum pl_redir Enum pl_redir contains the list of constants that define buffer redirection (shorting) for this platform.
  • Page 158: Enum Pl_Io_Num

    RX/W0&1in/din input of the serial port 2. 13- PL_IO_NUM_13_TX2 General-purpose I/O line 13 (P1.5). This line is also the TX/W1out/dout output of the serial port 2. 14- PL_IO_NUM_14_RX3 General-purpose I/O line 14 (P1.6). This line is also ©2000-2008 Tibbo Technology Inc.
  • Page 159 TIDE and Tibbo BASIC User Manual the RX/W0&1in/din input of the serial port 3. 15- PL_IO_NUM_15_TX3 General-purpose I/O line 15 (P1.7). This line is also the TX/W1out/dout output of the serial port 3. 16- PL_IO_NUM_16_INT0: General-purpose I/O line 16 (P2.0).
  • Page 160 I/O line as input. Do this through the io.num property of the object. Enum pl_int_num includes the following constants: PL_INT_NUM_0: Interrupt line 0 (mapped onto I/O line 16). PL_INT_NUM_1: Interrupt line 1 (mapped onto I/O line 17). ©2000-2008 Tibbo Technology Inc.
  • Page 161: Platform-Dependent Programming Information

    TIDE and Tibbo BASIC User Manual PL_INT_NUM_2: Interrupt line 2 (mapped onto I/O line 18). PL_INT_NUM_3: Interrupt line 3 (mapped onto I/O line 19). PL_INT_NUM_4: Interrupt line 4 (mapped onto I/O line 20). PL_INT_NUM_5: Interrupt line 5 (mapped onto I/O line 21).
  • Page 162 Depending on the mode of the serial port (see ser.mode you need to set the following: ser.mode RX/W1in/ RTS/ CTS/ W1out/ din input W0out/ W0&1in/ dout cout cin input output output ©2000-2008 Tibbo Technology Inc.
  • Page 163 TIDE and Tibbo BASIC User Manual Will auto- Will auto- Requires Requires PL_SER_MODE_UAR configure as configure configurati configuratio output as input on as n as input output Requires Requires PL_SER_MODE_WIE configuratio configuratio GAND n as output n as input PL_SER_MODE_CLO...
  • Page 164 There are limitations on what MAC you can set. When loading the MAC into the Ethernet controller the device always resets the first byte of this address to 0. For example, if you set the MAC to 1.2.3.4.5.6 then the actual MAC used by the device will be 0.2.3.4.5.6. ©2000-2008 Tibbo Technology Inc.
  • Page 165: Em1202 And Em1202W Platforms

    The difference between the EM1202 and EM1202W platforms is that the EM1202W additionally includes the (Wi-Fi) object, which works with an external GA1000 add-on module to function. All other features of these two platforms are exactly the same. Both platforms will be collectively referred to as "EM1202(W)". Memory Space ...
  • Page 166: Supported Objects

     — handles Wi-Fi interface (only available on the EM1202W platform,  requires GA1000 add-on module); — in charge of serial ports (UART, Wiegand, and clock/data modes);  — handles I/O lines, ports, and interrupts;  — controls graphical display panels (several types supported);...
  • Page 167 TIDE and Tibbo BASIC User Manual buffer of the serial port 2. 4- PL_REDIR_SER: Redirects RX data of the serial port or socket to the TX buffer of the serial port 3. 6- PL_REDIR_SOCK0: Redirects RX data of the serial port or socket to the TX buffer of socket 0.
  • Page 168 Selects general-purpose I/O line 16 (P2.0). PL_IO_NUM_17_INT1: Selects general-purpose I/O line 17 (P2.1). PL_IO_NUM_18_INT2: Selects general-purpose I/O line 18 (P2.2). PL_IO_NUM_19_INT3: Selects general-purpose I/O line 19 (P2.3). PL_IO_NUM_20_INT4: Selects general-purpose I/O line 20 (P2.4). PL_IO_NUM_21_INT5: Selects general-purpose I/O line 21 (P2.5). ©2000-2008 Tibbo Technology Inc.
  • Page 169: Enum Pl_Int_Num

    TIDE and Tibbo BASIC User Manual PL_IO_NUM_22_INT6: Selects general-purpose I/O line 22 (P2.6). PL_IO_NUM_23_INT7: Selects general-purpose I/O line 23 (P2.7). PL_IO_NUM_24: Selects general-purpose I/O line 24 (does not belong to any 8-bit port). PL_IO_NUM_25: Selects general-purpose I/O line 25 (does not belong to any 8-bit port).
  • Page 170: Enum Pl_Sock_Interfaces

    Each platform section in this manual has its own "Platform-dependent Programming Information" topic. If you are reading documentation top-to-bottom (we have never actually met anyone who does) you can skip this section now. ©2000-2008 Tibbo Technology Inc.
  • Page 171 TIDE and Tibbo BASIC User Manual You have to explicitly configure I/O lines as inputs or outputs On the EM1202(W) you need to explicitly enable or disable the output driver of each I/O line (controlled by the object). The io.enabled property allows you to do this.
  • Page 172 (and, actually, platform-independent) way -- see ser.div9600 property for details, (example of use can be found in the Serial Settings topic). For the beep object, you just have to set the beep.divider correctly depending on the value ©2000-2008 Tibbo Technology Inc.
  • Page 173 TIDE and Tibbo BASIC User Manual returned by the sys.currpll property. Data in the special configuration section of the EEPROM Bottom 8 bytes of the EEPROM (accessible through the stor object) are reserved for storing MAC address of the device. On power-up, the MAC address is read out from the EEPROM and programmed into the Ethernet controller.
  • Page 174: Em1206 And Em1206W Platforms

    The difference between the EM1206 and EM1206W platforms is that the EM1206W additionally includes the (Wi-Fi) object, which works with an external GA1000 add-on module to function. All other features of these two platforms are exactly the same. Both platforms will be collectively referred to as "EM1206(W)". Memory Space ...
  • Page 175: Supported Objects

    TIDE and Tibbo BASIC User Manual Supported Objects 8.1.4.2 The following objects are found on the EM1206(W): Sock — socket communications (up to 16 UDP, TCP, and HTTP sessions);  — controls Ethernet port;  — handles Wi-Fi interface (only available on the...
  • Page 176: Enum Pl_Io_Num

    When the line is configured for output, its output driver is enabled. It is possible to read the state of the line even when it is working as an output. Certain lines automatically become inputs and outputs in certain modes of ©2000-2008 Tibbo Technology Inc.
  • Page 177 TIDE and Tibbo BASIC User Manual operation -- see below for details. Enum pl_io_num includes the following constants: 0- PL_IO_NUM_0_RX0_INT0 General-purpose I/O line 0 (P0.0). This line is also the RX/W1in/din input of the serial port 0 and the interrupt line 0.
  • Page 178: Enum Pl_Int_Num

    Enum pl_sock_interfaces contains the list of network interfaces supported by the EM1206(W). The EM1206 and EM1206W platforms differ in that the EM1206W has a W-Fi interface, which the EM1206 does not, and the pl_sock_interfaces reflects this. EM1206 platform ©2000-2008 Tibbo Technology Inc.
  • Page 179: Platform-Dependent Programming Information

    TIDE and Tibbo BASIC User Manual 0- PL_SOCK_INTERFACE_NULL: Null (empty) interface. 1- PL_SOCK_INTERFACE_NET (default): Ethernet interface. EM1206W platform 0- PL_SOCK_INTERFACE_NULL: Null (empty) interface. 1- PL_SOCK_INTERFACE_NET (default): Ethernet interface. 2- PL_SOCK_INTERFACE_WLN: Wi-Fi interface. Platform-dependent Programming Information 8.1.4.4 This section contains miscellaneous information pertaining to the EM1206(W).
  • Page 180 "cannot transmit" the device will stop sending out data immediately. However, the data that has already entered the FIFO will still be sent out. Therefore, after the CTS state becomes "cannot transmit" the device can still send out up to 16 characters. There is a PLL ©2000-2008 Tibbo Technology Inc.
  • Page 181 TIDE and Tibbo BASIC User Manual On the EM1206(W) there is a PLL that, when switched on, increases the main clock of the device 8-fold (power cosumption also increases roughly by as much). When the PLL is off, the clock frequency of the device is 11.0592MHz; when the PLL is on the clock frequency is 88.4736MHz.
  • Page 182: Ds1202 Platform

    (common for T1000-based devices)  LED signals (common for all devices)  Debug communications (common for all devices)  Project Settings Dialog (common for all devices)  Supported Functions (common for T1000-based devices)  Supported Objects  ©2000-2008 Tibbo Technology Inc.
  • Page 183: Memory Space

    TIDE and Tibbo BASIC User Manual Platform-dependent Constants  Platform-dependent Programming Information  Memory Space 8.1.5.1 The platform has the following amounts of program (FLASH) and variable (RAM) memory available: Program memory: 983040 Bytes Variable memory: 20,480 bytes EEPROM memory:...
  • Page 184 20- PL_REDIR_SOCK14: Redirects RX data of the serial port or socket to the TX buffer of socket 14. 21- PL_REDIR_SOCK15: Redirects RX data of the serial port or socket to the TX buffer of socket 15. ©2000-2008 Tibbo Technology Inc.
  • Page 185: Enum Pl_Io_Num

    TIDE and Tibbo BASIC User Manual Enum pl_io_num Enum pl_io_num contains the list of constants that refer to I/O lines available on this platform. Use these constants when selecting the line with the object (see the io.num property). All I/O lines of the DS1202 platform require explicit configuration as inputs or outputs -- this is done through the io.enabled...
  • Page 186: Enum Pl_Int_Num

    PL_INT_NULL: This is a NULL interrupt line that does not physically exist. Enum pl_sock_interfaces Enum pl_sock_interfaces contains the list of network interfaces supported by the platform: 0- PL_SOCK_INTERFACE_NULL: Null (empty) interface. 1- PL_SOCK_INTERFACE_NET (default): Ethernet interface. ©2000-2008 Tibbo Technology Inc.
  • Page 187: Platform-Dependent Programming Information

    TIDE and Tibbo BASIC User Manual Platform-dependent Programming Information 8.1.5.4 This section contains miscellaneous information pertaining to the DS1202 platform. Various objects described in the Object Reference direct you to this topic in all cases when object capabilities or behavior depends on the platform and, hence, cannot be described in the object reference itself.
  • Page 188 To deal with PLL, the object has a sys.currentpll read-only property and sys.newpll method. See PLL Management topic- it explains how to switch PLL on and off. ©2000-2008 Tibbo Technology Inc.
  • Page 189 TIDE and Tibbo BASIC User Manual After the external reset (see sys.resettype ) the DS1202 boots with the PLL on or off depending on the state of the PE pin. For the serial port, there is a way to set the baudrate in the clock-independent (and, actually, platform-independent) way -- see ser.div9600...
  • Page 190: Ds1206 Platform

    (common for all devices)  Debug communications (common for all devices)  Project Settings Dialog (common for all devices)  Supported Functions (common for T1000-based devices)  Supported Objects  Platform-dependent Constants  Platform-dependent Programming Information  ©2000-2008 Tibbo Technology Inc.
  • Page 191: Memory Space

    TIDE and Tibbo BASIC User Manual Memory Space 8.1.6.1 The platform has the following amounts of program (FLASH) and variable (RAM) memory available: Program memory: 458,752 Bytes for the DS1206-512K; 983040 Bytes for the DS1206-1024K Variable memory: 20,480 bytes EEPROM memory:...
  • Page 192 20- PL_REDIR_SOCK14: Redirects RX data of the serial port or socket to the TX buffer of socket 14. 21- PL_REDIR_SOCK15: Redirects RX data of the serial port or socket to the TX buffer of socket 15. ©2000-2008 Tibbo Technology Inc.
  • Page 193: Enum Pl_Io_Num

    TIDE and Tibbo BASIC User Manual Enum pl_io_num Enum pl_io_num contains the list of constants that refer to I/O lines available on this platform. Use these constants when selecting the line with the object (see the io.num property). All I/O lines of the DS1206 platform require explicit configuration as inputs or outputs -- this is done through the io.enabled...
  • Page 194 Interrupt line 5 (mapped onto I/O line 5). PL_INT_NUM_6: Interrupt line 6 (mapped onto I/O line 6). PL_INT_NUM_7: Interrupt line 7 (mapped onto I/O line 7). PL_INT_NULL: This is a NULL interrupt line that does not physically exist. ©2000-2008 Tibbo Technology Inc.
  • Page 195: Enum Pl_Sock_Interfaces

    TIDE and Tibbo BASIC User Manual Enum pl_sock_interfaces Enum pl_sock_interfaces contains the list of network interfaces supported by the platform: 0- PL_SOCK_INTERFACE_NULL: Null (empty) interface. 1- PL_SOCK_INTERFACE_NET (default): Ethernet interface. Platform-dependent Programming Information 8.1.6.4 This section contains miscellaneous information pertaining to the DS1206 platform.
  • Page 196 8-fold (power cosumption also increases roughly by as much). When the PLL is off, the clock frequency of the device is 11.0592MHz; when the PLL is on the clock frequency is 88.4736MHz. ©2000-2008 Tibbo Technology Inc.
  • Page 197 TIDE and Tibbo BASIC User Manual The clock frequency affects all aspects of device operation that rely on this clock. Naturally, program execution speed depends on the clock frequency. Additionally, the baudrates of the serial port (defined by the ser.baudrate property) depend on the main clock.
  • Page 198: Common Information

     on_sys_timer event generation period depends on the value of this property. Common Information Supported Variable Types (T1000-based devices)  Supported Functions (T1000-based devices)  LED Signals  Debug Communications  Project Settings Dialog  ©2000-2008 Tibbo Technology Inc.
  • Page 199: Supported Variable Types (T1000-Based Devices)

    TIDE and Tibbo BASIC User Manual Supported Variable Types (T1000-based Devices) 8.1.7.1 The following variable types are supported by T1000-based devices:  Byte  Word  Dword  Char  Short (integer)  Long  Real (float)  Boolean  User-defined structures ...
  • Page 200: Led Signals

     When the device is in the serial upgrade mode, these LEDs indicate the status of firmware upload process.  When the device is under TiOS firmware control and Tibbo BASIC application is not running, these LEDs show current Tibbo BASIC application status.
  • Page 201: Debug Communications

    TIDE and Tibbo BASIC User Manual Fast-blinking BBBB... Tibbo BASIC application loaded but pattern (B= red and cannot run due to insufficient variable green together) (RAM) memory Fast-blinking G-G-G-... Tibbo BASIC application loaded but not pattern running. Fast-blinking R-R-R-... Tibbo BASIC application not loaded or pattern corrupted.
  • Page 202: Project Settings Dialog

    Additionally, you get to choose the type of the display panel. Disabling objects when they are not in use reduces the size of your compiled application binary. ©2000-2008 Tibbo Technology Inc.
  • Page 203: Device Explorer

    Comment: Additional information. For a device running fixed firmware, this is the owner name and the device name (does not apply to the EM1000). For a device running TiOS, this is the name of the Tibbo BASIC project currently loaded in memory.
  • Page 204 ("lasso"), or by holding SHIFT while pressing the arrow keys to move down or up the list. This allows you to perform certain operations en masse -- such as uploading TiOS to an entire group of devices, or deploying a Tibbo BASIC program on multiple devices, etc. Stand-Alone Mode This dialog was designed so it could be accessed also without running TIDE, or indeed, without TIDE even being installed on the system.
  • Page 205: Function Reference

    TIDE and Tibbo BASIC User Manual targets on his network. To access the dialog in stand-alone mode, run em202upgr.vbs. If You Cannot See Your Target There can be several possible causes why you cannot see your target. Two of the most common ones are: 1) The target is not connected to the same subnet as the computer.
  • Page 206: Bin Function

    In the release mode the Virtual Machine won't generate an exception, yet your application may need to know if a certain floating-point variable contains correct value. This is where cfloat function comes handy. Examples ©2000-2008 Tibbo Technology Inc.
  • Page 207: Chr Function

    TIDE and Tibbo BASIC User Manual real invalid_valid r1=10E30 v=cfloat(r1) 'v will return 0- VALID r1=r1*10E20 'at this point you will get FPERR exception if you are in the debug mode v=cfloat(r1) 'v will return 1- INVALID Chr Function Function: Returns the string that consists of a single character with ASCII code asciicode.
  • Page 208: Daycount Function

    12-DEC-2099 (day number 36524). Examples w = daycount(06, 10, 15) ' result will be 2479 (the serial day number for October 15th, 2006) Ddstr Function Function: Converts "dot-decimal value" into "dot-decimal string". Syntax: ddstr(byref str as string) as string ©2000-2008 Tibbo Technology Inc.
  • Page 209: Ddval Function

    TIDE and Tibbo BASIC User Manual Returns: A dot-separated string consisting of decimal representations of all binary values in the input string. Each decimal value will be in the 0-255 range. ddval See Also: Part Description String of binary values to be converted into a dot-decimal string.
  • Page 210: Ftostr Function

    -- fstr -- which is invoked implicitly whenever you assign a real to a string (string=real). Fstr is just like ftostr but mode and rnd parameters are fixed at 0- FTOSTR_MODE_AUTO and "maximum number of digits possible". Examples ©2000-2008 Tibbo Technology Inc.
  • Page 211: Hex Function

    TIDE and Tibbo BASIC User Manual as real as string 'demonstrate output formats r1=10000000000.0 'notice '.0' -- it is necessary or compilier will generate an error s=ftostr(r1,FTOSTR_MODE_ME,11) 'result will be '1E+010' s=ftostr(r1,FTOSTR_MODE_PLAIN,11) 'result will be '10000000000' s=ftostr(r1,FTOSTR_MODE_AUTO,11) 'result will be '1E+010' because this...
  • Page 212: Insert Function

    This will happen if the insertion position does not allow the source_str to fit within the current length of the dest_string. Examples s = "FLIGHT XXX STATUS" insert("123",8,s) 's will now be 'FLIGHT 123 STATUS' ©2000-2008 Tibbo Technology Inc.
  • Page 213: Instr Function

    TIDE and Tibbo BASIC User Manual Instr Function Function: Finds the Nth occurrence (defined by num, counting from 1) of a substring substr in a string sourcestr. Search is conducted from position frompos (leftmost character has position 1). Syntax: instr(frompos as byte,byref sourcestr as string, byref...
  • Page 214: Left Function

    Returns the length of (number of characters in) the string sourcestr. Syntax: len(byref sourcestr as string) as byte See Also: Part Description sourcestr String whose length needs to be calculated. Details Examples x = len("ABC") ' result will be 3 ©2000-2008 Tibbo Technology Inc.
  • Page 215: Lhex Function

    TIDE and Tibbo BASIC User Manual Lhex Function Function: Converts unsigned 32-bit numeric value (dword) into its HEX string representation. Syntax: lhex(byref num as dword) as string lstr stri lstri lbin See Also: lval Part Description Value to convert. Details Standard "&h"...
  • Page 216: Lstri Function

    'will be calculated at compilation -- no actual lstri function invokation will be here Lval Function Function: Converts string representation of a value into 32-bit value (dword or long). Syntax: lval(byref sourcestr as string) as dword lstr stri lstri lbin lhex See Also: ©2000-2008 Tibbo Technology Inc.
  • Page 217: Md5 Function

    TIDE and Tibbo BASIC User Manual Part Description sourcestr String to convert. Details Recognizes &b (binary) and &h (hexadecimal) prefixes. Can be invoked implicitly, through the dword_var= string_var expression (see example below). Compiler is smart enough to pre-calculate constant-only expressions involving implicit use of lval function.
  • Page 218: Mid Function

    Left Right See Also: Part Description sourcestr String from which to take the middle section. frompos First character to take. The leftmost character is counted to be at position 1. Number of characters to take. ©2000-2008 Tibbo Technology Inc.
  • Page 219: Mincount Function

    TIDE and Tibbo BASIC User Manual Details Examples s = mid("ABCDE",2,3) ' result will be 'BCD'. Mincount Function Function: Returns the minutes number for a given hours and minutes. Syntax: mincount(hours as byte, minutes as byte) as word Minute number elapsed since midnight (00:00). This Returns: value is in the 0-1439 range.
  • Page 220: Month Function

    10- PL_MONTH_OCTOBER: October. 11- PL_MONTH_NOVEMBER: November. 12- PL_MONTH_DECEMBER: December. year date weekday daycount hours See Also: minutes mincount Part Description daycount Day number. Base date for the day count is 1-JAN-2000 (this is day #0). Details ©2000-2008 Tibbo Technology Inc.
  • Page 221: Random Function

    TIDE and Tibbo BASIC User Manual Examples pl_months m = month(32) ' result will be PL_MONTH_FEBRUARY - day number 32 was in February 2000. Random Function Function: Generates a string consisting of len random characters. Syntax: random(len as byte) as string...
  • Page 222 SHA1 is a standard method of calculating hash codes on data of any size. The amount of input data can often exceed maximum capacity of string variables (255 characters). The sha1 method can be invoked repeatedly in order to process the data of any size (see the example below). Examples ©2000-2008 Tibbo Technology Inc.
  • Page 223: Str Function

    TIDE and Tibbo BASIC User Manual s, hash As String 'simple calculation on a short string s="Sting to calculate SHA1 on" hash=sha1(s,"",SHA1_FINISH,Len(s)) 'calculation on the entire contents of data in the 'text.txt 'file romfile.open("text.txt") hash="" s=romfile.getdata(192) 'use max portions While...
  • Page 224: Stri Function

    Examples as short as string sh= -3400 s = stri(sh) 'explicit invocation. s = sh 'implicit invocation s = stri(-100) 'will be calculated at compilation -- no actual stri function invokation will be here ©2000-2008 Tibbo Technology Inc.
  • Page 225: Strsum Function

    TIDE and Tibbo BASIC User Manual Strsum Function Function: Calculates 16-bit (word) sum of ASCII codes of all characters in a string. Syntax: strsum(byref sourcestr as string) as word See Also: Part Description sourcestr String to work on Details This function is useful for checksum calculation.
  • Page 226: Val Function

    = s 'implicit invocation "2402" 'be calculated at compilation -- no actual val function invokation will be here Vali Function Vali function is no longer available. Use function both for unsigned (word) and signed (short) conversions. ©2000-2008 Tibbo Technology Inc.
  • Page 227: Weekday Function

    TIDE and Tibbo BASIC User Manual Weekday Function Function: Returns the day of the week for a given day number. Syntax: weekday(daycount as word) as pl_days_of_week One of pl_days_of_week constants: Returns: 1- PL_DOW_MONDAY: Monday. 2- PL_DOW_TUESDAY: Tuesday. 3- PL_DOW_WEDNESDAY: Wednesday.
  • Page 228: Object Reference

    The sys object provides a very important event- on_sys_init . This event is guaranteed to be generated first when your device starts running. Therefore, you should put all your initialization code for sockets, ports, .etc into the event handler for this event: ©2000-2008 Tibbo Technology Inc.
  • Page 229: Buffer Management

    TIDE and Tibbo BASIC User Manual on_sys_init net.ip="192.168.1.95" sock.num=0 sock.targetip= "192.168.1.96" '...and everything else that you may need! end sub Buffer Management How to allocate buffer memory Some objects, such as the sock , rely on buffers for storing the data being sent and received.
  • Page 230: System Timer

    The system object provides a timer event- on_sys_timer - that is generated periodically. The period depends on the platform. If the platform doesn't have a sys.onsystimerperiod property, then this period is fixed at 0.5 seconds. If the ©2000-2008 Tibbo Technology Inc.
  • Page 231: Pll Management

    PLL is a module of the device that transforms the clock generated by onboard crystal into higher frequency (x8 of the base for Tibbo devices). When the PLL is on, the device runs at 8 times the base frequency, when the PLL is off, the device runs at a "native"...
  • Page 232: Serial Number

    Serial Number Tibbo devices currently in production use newer flash memory ICs featuring security register. This is a 128-byte register that has two 64-byte fields. The first field is one-time programmable, and the second field is pre-programmed at the factory and contains a unique serial number.
  • Page 233: Miscellaneous

    TIDE and Tibbo BASIC User Manual Miscellaneous sys.version property returns the version of the TiOS (firmware) running on your device. sys.halt method can be used to halt the execution of your program. For example, you can use this to halt the program when the Ethernet interface failure is detected: net.failure= YES...
  • Page 234: Currentpll R/O Property (Selected Platforms Only)

    PLL to default state (typically ON). On some devices there is a hardware jumper that defines the post-external reset state of the PLL. Not all Tibbo devices have PLL- check "Platform-dependent Programming Information" topic inside your platform specifications section to find out if there is a PLL on your platform.
  • Page 235: Halt Method

    PLL to default state (typically ON). On some devices there is a hardware jumper that defines the post-external reset state of the PLL. Not all Tibbo devices have PLL- check "Platform-dependent Programming Information" topic inside your platform specifications section to find out if there is a PLL on your platform.
  • Page 236: Onsystimerperiod Property (Selected Platforms Only)

    Value Range: 0-255. Default= 50 (500ms). See Also: Details Defines, in 10ms increments, the period at which the on_sys_timer event will be generated. Platforms that do not support this property have the period fixed at 0.5 seconds. ©2000-2008 Tibbo Technology Inc.
  • Page 237: Reboot Method

    TIDE and Tibbo BASIC User Manual .Reboot Method Function: Causes your device to reboot. sys.reboot Syntax: Returns: sys.currentpll sys.runmode sys.resettype , and See Also: sys.halt Details After the device reboots it will behave as after any other reboot: enter PAUSE...
  • Page 238: Setserialnum Method

    The serial number is stored in the security register of the flash IC. Older generation of flash ICs used in Tibbo devices did not have the security register. This method will return 1- NG if you attempt to set the serial number of the device that does not have the security register.
  • Page 239: Timercount R/O Property

    TIDE and Tibbo BASIC User Manual Details Internal resets are generated when the device self-reboots. This can be caused by the execution of sys.reboot in your application, or command from TIDE. External resets are the ones that are caused by power-cycling (turning the device off and back on) or applying a reset pulse to the RTS line of the device (pushing reset button).
  • Page 240: Ser Object

     Buffer shorting feature for fast data exchange between the ser object and other objects (such as the sock object) that support standard Tibbo Basic data buffers. For the UART mode:  Ability to set any baudrate (that is physically possible on a particular platform) by specifying "divider value"...
  • Page 241: Overview

    The buffers available are:  The TX buffer, which contains data due to be sent out of the port (i.e, it's the transmit of your device!). Your Tibbo Basic application puts the data into the TX buffer.  The RX buffer, which contains incoming data received by the port. This data is to be processed by your application.
  • Page 242: Uart Mode

    TX buffer will be ignored. Parity bits are not stored in the buffers. For the outgoing data stream, the serial port will calculate and append the parity bit automatically. For the incoming serial data, the ©2000-2008 Tibbo Technology Inc.
  • Page 243 The serial port will stop sending the data once the line goes high. Note, that some Tibbo devices have a hardware buffer called "FIFO" ("fist-in-first-out" if you really need to know ;-). Once the TX data is in the FIFO it will be sent out even if the CTS line goes low.
  • Page 244 (the TX buffer is not empty) it switches the RTS line into the "data out" state, transmits the data, then switches the RTS back into the "data in" state. Assuming "LOWFORINPUT" direction control polarity, direction control looks like this: ©2000-2008 Tibbo Technology Inc.
  • Page 245: Wiegand Mode

    TIDE and Tibbo BASIC User Manual The CTS line is not controlled by the serial port when in the half-duplex mode. Your application can manipulate this line through the object. Wiegand Mode In the Wiegand mode the serial port is able to receive the data directly from any Wiegand device, such as card reader and also output the data in the Wiegand format, as if it was a card reader itself.
  • Page 246 You already know that W0&1in input of the serial port must receive a logical AND of W0 and W1 output of attached Wiegand device. A simple AND gate will do the job (figure A below). Actually, NOR-AND gates are more popular and these can be ©2000-2008 Tibbo Technology Inc.
  • Page 247 TIDE and Tibbo BASIC User Manual used too (figure B). In case you are building a product that will also accept clock/ data input, you may need to control whether the W0&1in input should receive a logical AND of two lines, or just one of the lines. Schematic diagram C uses an additional I/O line of the device to control this.
  • Page 248: Clock/Data Mode

    Compared to Wiegand interface, the data format of clock/data interface is very standardized and its varieties include standard data formats for different "tracks" of the magnetic card. Most clock/data devices you will actually encounter have nothing to do with magnetic cards but terminology persists. ©2000-2008 Tibbo Technology Inc.
  • Page 249 TIDE and Tibbo BASIC User Manual The serial port outputs clock/data signals through cout and dout lines and receives the data via cin and din lines. Your application should not attempt to work with cout and dout outputs directly through the object when the serial port is in the clock/data mode.
  • Page 250: Port Selection

    Since there can be multiple ports, you must state which port you are referring to when changing properties or invoking methods. This is done using the ser.num property. For example: ser.mode = PL_SER_MODE_WIEGAND ©2000-2008 Tibbo Technology Inc.
  • Page 251 TIDE and Tibbo BASIC User Manual Can you tell what serial port the statement above applies to? Neither can the platform. Thus, the correct syntax would be: ser.num = ser.mode = PL_SER_MODE_WIEGAND Now the platform knows what port you're working with. Once you have set the port selector (using ser.num), every method and property after that point is taken to...
  • Page 252: Serial Settings

    W0out/cout output and CTS/W0&1in/cin input, i.e. choose what I/O pins of the device these lines should be on. See "Platform-dependent Programming Information" topic inside your platform specifications section. If your device supports remapping, you can use ser.ctsmap ser.rtsmap properties to ©2000-2008 Tibbo Technology Inc.
  • Page 253 TIDE and Tibbo BASIC User Manual select required mapping. If your device does not support remapping then its platform will not have these properties. You can only perform remapping when the serial port is closed. UART, Wiegand, or clock/data mode selection ser.mode...
  • Page 254 Escape sequences are rather arbitrary. They follow the style of escape sequences that Tibbo introduced before. However, they are useful for certain things. For example , if your application has a normal mode and serial 'setup' mode, you can use this sequence to switch into setup mode.
  • Page 255: Sending And Receiving Data (Tx And Rx Buffers)

    TIDE and Tibbo BASIC User Manual serial programming mode or perform some other similar task. Sending and Receiving Data (TX and RX buffers) The serial port sends and receives data through TX (transmit) and RX (receive) buffers. Read on and you will know how to allocate memory for buffers, use them, handle overruns, and perform other tasks related to sending and receiving of data.
  • Page 256: Using Buffers

    Can you add more data? etc. Thus, each of the serial buffers has certain properties which allow you to monitor it: The RX buffer You can check the total capacity of the buffer with the ser.rxbuffsize property. ©2000-2008 Tibbo Technology Inc.
  • Page 257: Receiving Data

    TIDE and Tibbo BASIC User Manual You can also find out how much committed data the RX buffer currently contains with the ser.rxlen property (see Serial Settings for explanation of what committed data is). Sometimes you need to clear the RX buffer without actually extracting the data. In such cases the ser.rxclear...
  • Page 258 TX buffer. The first line of this code implements just that: Ser.getdata method takes as much data from the RX buffer as possible, but not more than ser. txfree (the available room in the TX buffer). The second line just sends the data. ©2000-2008 Tibbo Technology Inc.
  • Page 259: Sending Data

    TIDE and Tibbo BASIC User Manual Actually, this call will handle no more than 255 bytes in one pass. Even though we seemingly copy the data directly from the RX buffer to the TX buffer, this is done via a temporary string variable automatically created for this purpose.
  • Page 260: Handling Buffer Overruns

    If you try to add more data to the TX buffer than the free space in the buffer allows to store then the data you are adding will be truncated. Sending Data for explanation on how to TX data correctly. ©2000-2008 Tibbo Technology Inc.
  • Page 261: Redirecting Buffers

    TIDE and Tibbo BASIC User Manual Redirecting Buffers The following example appeared under Receiving Data on_ser_data_arrival ser.setdata(ser.getdata(ser.txfree)) ser.send end sub This example shows how to send all data incoming to the RX buffer out from the TX buffer, in just two lines of code. However fast, this technique still passes all data through your BASIC code, even though you are not processing (altering, sampling) it in any way.
  • Page 262: Properties, Methods, Events

    Ser.baudrate ser.parity ser.bits ser.esctype , and ser.interface only relevant in the UART mode of operation. Ser.escchar is only relevant when ser.esctype is not DISABLED. ©2000-2008 Tibbo Technology Inc.
  • Page 263 TIDE and Tibbo BASIC User Manual ©2000-2008 Tibbo Technology Inc.
  • Page 264: Autoclose Property

    (9600*12)/38400=3. This serves as a platform-independent baudrate calculation, as ser.div9600 will return different values for different platforms. This property is only relevant when the serial port is in the UART mode (ser.mode = 0- PL_SER_MODE_UART). ©2000-2008 Tibbo Technology Inc.
  • Page 265: Bits Property

    TIDE and Tibbo BASIC User Manual Technically speaking, this property should be called divisor, not baudrate. We called it baudrate so that you could easily find it. .Bits Property Function: Specifies the number of data bits in a word TXed/RXed by...
  • Page 266: Dircontrol Property

    Type: Word Value Range: See Also: Serial Settings Details "Smart" applications will use this property to set baudrates in a platform- independent fashion. Even for the same device, the value required to achieve ©2000-2008 Tibbo Technology Inc.
  • Page 267: Enabled Property

    TIDE and Tibbo BASIC User Manual 9600bps may be different at different times. For example, some devices have PLLs (see sys.currentpll ). Enabling and disabling PLL changes the clock frequency of the device and this affects the value returned by ser.div9600.
  • Page 268 The side effect and the point this example illustrates is that first two escape characters were lost -- they neither became a part of a successful escape sequence (because this sequence wasn't completed), nor were saved into the buffer. ©2000-2008 Tibbo Technology Inc.
  • Page 269: Flowcontrol Property

    TIDE and Tibbo BASIC User Manual Type 2 Type 2 escape sequence is not based on any timing. Escape sequence consists of escape character (defined by the ser.escchar property) followed by any character other than escape character. To receive a data character whose ASCII code matches that of escape character the serial port must get this character twice.
  • Page 270: Interchardelay Property

    For Wiegand and clock/data modes, counting timeout since the last bit is the only way to determine the end of the data output. Suggested timeout is app. 10 times the bit period of the data output by attached Wiegand or clock/data device. ©2000-2008 Tibbo Technology Inc.
  • Page 271: Interface Property

    TIDE and Tibbo BASIC User Manual .Interface Property Chooses full-duplex or half-duplex operating mode for Function: currently selected serial port (selection is made through ser.num Enum (pl_ser_interface, byte) Type: 0- PL_SER_SI_FULLDUPLEX (default): full-duplex mode. Value Range: 1- PL_SER_SI_HALFDUPLEX: half-duplex mode.
  • Page 272: Newtxlen R/O Property

    0-65535, default= 0 (bytes) Value Range: See Also: Sending (Transmitting) Data ser.txlen ser.txfree Details Uncommitted data is the one that was added to the TX buffer with the ser.setdata method but not yet committed using the ser.send method. ©2000-2008 Tibbo Technology Inc.
  • Page 273: Notifysent Method

    TIDE and Tibbo BASIC User Manual .Notifysent Method Using this method for the selected serial port (selection is Function: made through ser.num ) will cause the on_ser_data_sent event to be generated when the amount of committed data in the TX buffer is found to be below "threshold"...
  • Page 274: Numofports R/O Property

    Generated after the total amount of committed data in the TX buffer of the serial port (ser.txlen ) is found to be less than the threshold that was preset through the ser. notifysent method. Declaration: on_ser_data_sent See Also: Sending (Transmitting) Data ©2000-2008 Tibbo Technology Inc.
  • Page 275: On_Ser_Esc Event

    TIDE and Tibbo BASIC User Manual Details This event may be generated only after the ser.notifysent method was used. Your application needs to use the ser.notifysent method EACH TIME it wants to cause the on_ser_data_sent event generation for a particular port. When the event handler for this event is entered the ser.num...
  • Page 276: Parity Property

    The redir argument, as well as the value returned by this method are of "enum pl_redir" type. The pl_redir defines a set of platform inter-object constants that ©2000-2008 Tibbo Technology Inc.
  • Page 277: Rtsmap Property (Selected Platforms Only)

    TIDE and Tibbo BASIC User Manual include all possible redirections for this platform. Specifying redir value of 0- PL_REDIR_NONE cancels redirection. When the redirection is enabled for a particular serial port, the on_ser_data_arrival event is not generated for this port.
  • Page 278: Rxbuffrq Method

    The ser.rxbuffrq requests buffer size in 256-byte pages whereas this property returns buffer size in bytes. Relationship between the two is as follows: ser. rxbuffsize=num_pages*256-16 (or =0 when num_pages=0), where "num_pages" is the number of buffer pages that was GRANTED through the ser.rxbuffrq. "-16" is ©2000-2008 Tibbo Technology Inc.
  • Page 279: Rxclear Method

    TIDE and Tibbo BASIC User Manual because 16 bytes are needed for internal buffer variables. The serial port cannot RX data when the RX buffer has zero capacity. .Rxclear Method Function: For the selected serial port (selection is made through ser.
  • Page 280: Send Method

    This allows your application to prepare large amounts of data before sending it out. Total amount of newly added (uncommitted) data in the buffer can be checked through the ser.newtxlen setting. ©2000-2008 Tibbo Technology Inc.
  • Page 281: Sinkdata Property

    TIDE and Tibbo BASIC User Manual .Sinkdata Property For the currently selected serial port (selection is made Function: through ser.num ) specifies whether the incoming data should be discarded. Enum (yes_no, byte) Type: 0- NO (default): normal data processing. Value Range: 1- YES: discard incoming data.
  • Page 282: Txbuffsize R/O Property

    .Txfree R/O Property For the selected serial port (selection is made through Function: ser.num ) returns the amount of free space in the TX buffer in bytes. Word Type: 0-65535 Value Range: See Also: Buffer Memory Status ©2000-2008 Tibbo Technology Inc.
  • Page 283: Txlen R/O Property

    TIDE and Tibbo BASIC User Manual Details Notice, that the amount of free space returned by this property does not take into account any uncommitted data that might reside in the buffer (this can be checked ser.newtxlen ). Therefore, actual free space in the buffer is ser.txfree-ser.
  • Page 284: Overview

    MAC is stored in the special configuration area of the EEPROM. Access to the EEPROM is provided by the stor object. To change the MAC address you need to rewrite the data in the EEPROM. For more details, see the Stor Object Stor. Base Property topics. ©2000-2008 Tibbo Technology Inc.
  • Page 285: Checking Ethernet Status

    TIDE and Tibbo BASIC User Manual Checking Ethernet Status net.failure read-only property tells you if the NIC is functioning properly. net.linkstate read-only property tells you if there is a live Ethernet cable plugged into the Ethernet port of your device, and, if yes, whether this is a 10BaseT or 100BaseT connection.
  • Page 286: Ip Property

    .Gatewayip Property Sets/returns the IP address of the default gateway for the Function: Ethernet interface of your device. String Type: Any valid IP address, such as "192.168.100.40". Default Value Range: = "127.0.0.1" See Also: net.ip net.netmask ©2000-2008 Tibbo Technology Inc.
  • Page 287: Failure R/O Property

    TIDE and Tibbo BASIC User Manual Details This property can only be written to when no socket is engaged in communications through the Ethernet interface, i.e. there is no socket for which sock.statesimple <> 0- PL_SSTS_CLOSED and sock.currentinterface = 1- PL_INTERFACE_ETHERNET.
  • Page 288: On_Net_Overrun Event

    (firmware) file into the device through the serial port. The button is not doing anything system-related at other times, so it can be used by your Tibbo BASIC application -- hence, the button object. The object offers the folloing: button.pressed property returns current (immediate) state of the button.
  • Page 289: On_Button_Pressed Event

    TIDE and Tibbo BASIC User Manual on_button_released 'see how much time has elapsed button.time>4 then 'the button for pressed for a "long" time -- do one thing else 'the button was pressed for a "short" time -- do another thing...
  • Page 290: Pressed R/O Property

    On other programming systems, sockets are often dynamic, created and destroyed as needed. With TiOS, you receive a preset number of sockets which have already been created for you, and just use them. A socket may be idle, but it will still be there. ©2000-2008 Tibbo Technology Inc.
  • Page 291: Overview

     Adjustable receive (RX), transmit (TX), and other buffer sizes for optimal RAM utilization.  Buffer shorting feature for fast data exchange between the sock object and other objects (such as the object) that support standard Tibbo Basic data buffers. Overview 8.3.5.1 This section covers the socket object in detail.
  • Page 292: Anatomy Of A Socket

    = Now the platform knows which socket you're working with. Once you have set the socket selector (using sock.num), every socket-specific method and property after that point is taken to refer to that socket. Thus: ©2000-2008 Tibbo Technology Inc.
  • Page 293: Handling Network Connections

    TIDE and Tibbo BASIC User Manual sock.num = sock.protocol = sock.connectiontimeout = sock.httpmode = ' etc The events for this object are not separate for each socket. An event such as on_sock_data_arrival serves all sockets on your platform. Thus, when an event...
  • Page 294: Tcp Connection Basics

    "UDP datagrams". This is similar to "paging" (as in, sending a message with a "pager" -- remember those?). What is sent is a packet containing some data. There is no guarantee that the other side will receive ©2000-2008 Tibbo Technology Inc.
  • Page 295: Accepting Incoming Connections

    TIDE and Tibbo BASIC User Manual the packet and the sender won't know whether the packet was received or not. Each UDP datagram lives its own life and you are responsible for dividing your data into chunks of reasonable size and sending it in separate datagrams. There is no connection establishment or termination on UDP- the datagram can be sent instantly, without any preparation.
  • Page 296 In this example, if there is an incoming connection targeting "our" port 80 and the protocol is TCP then the mode will be HTTP- the sock.httpportlist has priority over sock.localportlist. Of course, for UDP the sock.httpportlist won't matter since the ©2000-2008 Tibbo Technology Inc.
  • Page 297: Accepting Udp Broadcasts

    TIDE and Tibbo BASIC User Manual HTTP is only possible on TCP! Setting allowed interfaces The sock object is interface-independent and supports communications over more than one interface. The sock.allowedinterfaces property defines the list of interfaces on which the current socket will accept incoming connections. The list is different and depends on the platform.
  • Page 298 1- PL_SOCK_RECONMODE_1. This way, reconnects will only be accepted from the same IP and the same port as the original connection. Total promiscuity -- mode 3! Finally, there is a mode (3- PL_SOCK_RECONMODE_3) when the socket will accept ©2000-2008 Tibbo Technology Inc.
  • Page 299: Understanding Udp Reconnects And Port Switchover

    TIDE and Tibbo BASIC User Manual a reconnect from any host or port. Basically, this means, that whatever connection is in progress, it will be interrupted and replaced by any other incoming connection. Do not use reconnects for HTTP sockets! Reconnects and HTTP do not play nicely together.
  • Page 300 'we are dealing with UDP sock.inconmode= PL_SOCK_INCONMODE_ANY_IPPORT sock.reconmode= PL_SOCK_RECONMODE_2 'reconnects accepted from the same IP, any port, port switchover on sock.localportlist= "3000" sock.targetport= "900" Two hosts are sending us datagrams and here is how the socket will react: ©2000-2008 Tibbo Technology Inc.
  • Page 301 TIDE and Tibbo BASIC User Manual Incoming datagram Socket reaction 192.168.100.40:1000 sends UDP Datagram accepted, UDP "connection" datagram to the port 3000 of our is now in progress, the socket will be device sending all further outgoing datagrams to 192.168.100.40:1000.
  • Page 302: Incoming Connections On Multiple Sockets

    "1001" sock.num=1 sock.protocol= PL_SOCK_PROTOCOL_TCP sock.inconmode= PL_SOCK_INCONMODE_ANY_IPPORT sock.localportlist= "1001" sock.num=2 sock.protocol= PL_SOCK_PROTOCOL_UDP sock.inconmode= PL_SOCK_INCONMODE_ANY_IPPORT sock.localportlist= "2000" Here is a sample sequence of incoming connections and how the setup above would handle them: Incoming datagram Socket reaction ©2000-2008 Tibbo Technology Inc.
  • Page 303: Establishing Outgoing Connections

    TIDE and Tibbo BASIC User Manual Incoming TCP connection to port 1001 Connection will be accepted on socket from host 192.168.100.40:29600 0 since this socket lists 1001 as one of the listening ports and this incoming connection request is from "correct"...
  • Page 304: Sending Udp Broadcasts

    1- YES: sock.targetbcast= YES sock.setdata("ABC") 'this is explained in 'Working With Buffers' section sock.send 'this is explained in 'Working With Buffers' section sock.connect 'broadcast UDP datagram with string 'ABC' will be sent out at this point ©2000-2008 Tibbo Technology Inc.
  • Page 305 TIDE and Tibbo BASIC User Manual There is one difference to grasp regarding the socket that is sending its outgoing packets as broadcasts: no incoming UDP packet that would have normally be interpreted as a re-connect will cause the socket to "switchover" to the source IP- address of the packet.
  • Page 306: Closing Connections

    In both cases the socket will handle connection closing automatically, without any help from your Tibbo BASIC program or the VM. In fact, the socket will accept connection termination even when the VM is stopped (for example, it was paused on your breakpoint).
  • Page 307 TIDE and Tibbo BASIC User Manual Just like with connection establishment, you can monitor the progress of connection termination- see Checking Connection Status Notice, that depending on the socket state at the moment of sock.close method invocation, the socket may need to resort to a simple connection closing option- reset or discard.
  • Page 308: Checking Connection Status

    (socket is idle). It doesn't tell you, however, why it is closed. "Detailed" state PL_SST_CL_ARESET_CMD tells you that connection is closed because there was an active close as a result of the sock.close method invocation from your program! On_sock_event and sock.event, sock.eventsimple read-only properties ©2000-2008 Tibbo Technology Inc.
  • Page 309 -- "newstatesimple". These arguments contains the state of the socket at the moment when the on_sock_event was generated. Newstate and newstatesimple arguments have been introduced in Tibbo Basic V2.0. Before, their role was played by two read-only properties -- sock.event...
  • Page 310: More On The Socket's Asynchronous Nature

    There are certain situations when your program has to take the above into account. Here is one example. Supposing, we want to know the MAC address of a remote device to which we are establishing an outgoing connection. Naturally, we can do it this way: ©2000-2008 Tibbo Technology Inc.
  • Page 311 TIDE and Tibbo BASIC User Manual 'Correct code -- on startup we order the connection to be established and in the on_sock_event event handler we record the MAC address of the 'other side' On_sys_init sock.targetip="192.168.100.40" 'we prepare for the connection sock.targetport=2000...
  • Page 312 Of course, now that you have at least one doevents in the event handler you might as well add doevents in all "places of waiting" -- just to let other events execute sooner. ©2000-2008 Tibbo Technology Inc.
  • Page 313: Sending And Receiving Data

    TIDE and Tibbo BASIC User Manual 'Even better code! sock.close While sock.statesimple<>PL_SSTS_CLOSED 'here we wait for the connection to be closed doevents 'Not necessary but useful -- lets other events execute Wend doevents ' Absolutely essential for this particular case! sock.connect...
  • Page 314: Using Buffers In Tcp Mode

    The data can be stored in the TX buffer at any time but it will only be sent out if and when the network connection is established. Storing the data in the TX buffer won't cause the socket to establish any connection automatically. Receiving Data ©2000-2008 Tibbo Technology Inc.
  • Page 315: Using Buffers In Udp Mode

    TIDE and Tibbo BASIC User Manual Receiving data is a one-step process. To extract the data from the RX buffer, use sock.getdata method. Data may only be extracted once from the buffer. Once extracted, it is no longer in the buffer. For example:...
  • Page 316: Tx And Rx Buffer Memory Status

    . The txlen property returns the amount of committed data waiting to be sent from the buffer (you commit the data by using the sock.send method). The newtxlen property returns the amount of data which has entered the buffer, but has not yet ©2000-2008 Tibbo Technology Inc.
  • Page 317: Receiving Data In Tcp Mode

    TIDE and Tibbo BASIC User Manual been committed for sending. For UDP, this is basically the length of UDP datagram being created. The TX buffer also has a sock.txfree property, which directly tells you how much space is left in it. This does not take into account uncommitted data in the buffer -- actual free space is sock.txfree-sock.newtxlen!
  • Page 318 RX buffer to the TX buffer, this is done via a temporary string variable automatically created for this purpose. In this platform, string variables cannot exceed 255 bytes. ©2000-2008 Tibbo Technology Inc.
  • Page 319: Receiving Data In Udp Mode

    TIDE and Tibbo BASIC User Manual Receiving Data in UDP Mode In the previous section we have already explained how to handle data reception when the socket is in the TCP mode. This section provides explanation for receiving data with UDP.
  • Page 320: Sending Tcp And Udp Data

    "This is a long string waiting to be sent. Send me already!" while sock.txfree < len(s) wend sock.setdata(s) sock.send end sub Again, this is not so good, as it would block other event handlers. So, instead of doing that, we would employ a code that uses on_sock_data_sent ©2000-2008 Tibbo Technology Inc.
  • Page 321 TIDE and Tibbo BASIC User Manual as string "This is a long string waiting to be sent. Send me already!" on_button_pressed sock.notifysent(sock.txbuffsize-len(s)) ' causes the on_sock_data_sent event to fire when the TX buffer has space for our string end sub on_sock_data_sent sock.setdata(s)
  • Page 322: Split Packet" Mode Of Tcp Data Processing

    TCP packets. For example, as it turns out, some data encryption methods work on a packet level. Erase the border between TCP packets -- and you can't decrypt the data. Introduced in Tibbo Basic V2.0, new sock.splittcppackets property and...
  • Page 323: Handling Buffer Overruns

    TIDE and Tibbo BASIC User Manual data into the TX buffer and execute sock.send , the socket won't send this data out unless entire contents of the TX buffer can be sent out in a single TCP packet. Here is an example of how you can use that: sock.splittcppackets=YES...
  • Page 324: Redirecting Buffers

    The receiving socket will still send out the data subdivided into the original datagrams. When an RX buffer of a UDP socket is redirected to a TX buffer of a TCP socket or serial port, the service information is removed and datagram boundaries are ©2000-2008 Tibbo Technology Inc.
  • Page 325: Sinking Data

    TIDE and Tibbo BASIC User Manual dissolved. To the receiving TCP socket or serial port, the data appears to be a stream. Sinking Data Sometimes it is desirable to ignore all incoming data while still maintaining the connection opened. The sock.sinkdata...
  • Page 326: Inband-Related Buffers (Cmd, Rpl, And Tx2)

     The TX2 buffer- used internally by the socket when inband commands are enabled. You don't have to do anything with this buffer other than allocate memory for it. We recommend allocating as much space as you did for the TX ©2000-2008 Tibbo Technology Inc.
  • Page 327: Processing Inband Commands

    TIDE and Tibbo BASIC User Manual buffer. Allocation is requested through the sock.tx2buffrq method. Actual memory allocation is done through the sys.buffalloc method which applies to all buffers previously specified. Here is an example: b1, b2, b3, b4, b5 as byte 'setup for other objects, sockets, etc.
  • Page 328 Inband commands only appear in the CMD buffer in their entirety. That is, if the buffer was previously empty and you get the on_sock_inband event then you are guaranteed that the buffer will contain a full command (or several full commands). Here is an example: ©2000-2008 Tibbo Technology Inc.
  • Page 329: Sending Inband Replies

    TIDE and Tibbo BASIC User Manual on_sock_inband as string 'we will keep the data from the CMD buffer here as string 'this will keep individual inband commands as byte s=sock.getinband 'we get entire CMD buffer contents into the s x=instr(1,s,chr(sock.endchar)) while x<>0...
  • Page 330: Using Http

    Certain BASIC information about the HTTP server has already been provided in Working with HTML Embedding Code Within an HTML File When the socket is in the HTTP mode your program has no control over the received data (HTTP requests) and only sometimes has control over the ©2000-2008 Tibbo Technology Inc.
  • Page 331: Http-Related Buffers

    HTML file in your project does not exceed 65534 bytes. 65534 is actually the size limitation for the compiled HTML file. When compiling your project, the TIDE will separate the static portion of the file from the Tibbo Basic code fragments. Only the compiled file size matters. HTTP-related Buffers For the HTTP to work, you need to allocate some memory to the following buffers: ...
  • Page 332 (sock.statesimple is not PL_SSTS_CLOSED), the socket will be automatically closed. Whatever connection you had in progress will be discarded. The socket will not be closed if its buffer sizes remain unchanged. ©2000-2008 Tibbo Technology Inc.
  • Page 333: Setting The Socket For Http

    TIDE and Tibbo BASIC User Manual Notice, that in most cases you will need to reserve more than one socket for HTTP. The HTTP server may need to service multiple requests from different computers at the same time. Even for a single computer and a single HTML page, more than one socket may be needed.
  • Page 334: Socket Behavior In The Http Mode

    HTTP connection request), and if your application has one or more sockets that are configured to accept this connection, and if all such sockets are already occupied, then the system will not reply to the requesting host at all. ©2000-2008 Tibbo Technology Inc.
  • Page 335: Including Basic Code In Http Files

    TIDE and Tibbo BASIC User Manual  If there is an incoming HTTP connection request, and if your application has no HTTP sockets configured to accept this connection, then the system will still respond with a reset. This behavior allows your application to get away with fewer HTTP sockets. Here is why.
  • Page 336: Generating Dynamic Html Pages

    "call you back" when the TX buffer frees up! The only solution in case of HTTP is to wait, in a loop, for the desired amount of space to become available. Naturally, we don't want to be blocking the whole ©2000-2008 Tibbo Technology Inc.
  • Page 337 TIDE and Tibbo BASIC User Manual device, so "polite" waiting shall include a doevents statement: <? string(4) ?> <!DOCTYPE HTML public "-//W3C//DTD W3 HTML//EN"> <HTML> <BODY> The state of line is:!<br> <? 'This is a BASIC code snippet. Get the state of the line.
  • Page 338: Url Substitution

    . Actual HTML contents received by the browser may partially be generated by your Tibbo BASIC application. Files of other types -- plain text, graphics, etc. -- cannot include executable code and are static in nature. These files are sent to the browser "as is".
  • Page 339: Tide And Tibbo Basic User Manual

    TIDE and Tibbo BASIC User Manual Working with HTTP Variables HTML pages often pass "variables" to each other. For example, if you have an HTML form to fill on page "form.html" you may want to have the data input by the user on page "result.html".
  • Page 340: Complex Case (Large Amount Of Variable Data)

    OK, so now you have a chance to access and process the HTTP variable data as it arrives and before the reply phase even starts. The sock.gethttprqstring method, unlike the sock.httprqstring R/O property, actually removes the data from the VAR buffer, thus freeing up the buffer space. Diagram below illustrates the process: ©2000-2008 Tibbo Technology Inc.
  • Page 341 TIDE and Tibbo BASIC User Manual Here is a modified login example: In the event handler for the on_sock_postdata event we extract available HTTP variable data and process it. The event will be called as many times as necessary. For example, we may save the data into a file: On_sock_postdata() fd.setdata(sock.gethttprqstring(255))
  • Page 342: Details On Variable Data

    VAR buffer contents -- HTTP POST method Here is a sample client request: POST /form_get.html HTTP/1.1 Host: 127.0.0.1:1000 User-Agent: Mozilla/5.0 (lots of stuff skipped) Content-Type: multipart/form-data; boundary=--------------------------- 21724139663430 Content-Length: 257 -----------------------------21724139663430 Content-Disposition: form-data; name="user" CHUCKY -----------------------------21724139663430 Content-Disposition: form-data; name="pwd" THEEVILDOLL -----------------------------21724139663430-- ©2000-2008 Tibbo Technology Inc.
  • Page 343: Properties, Methods, And Events

    TIDE and Tibbo BASIC User Manual You will get everything shown in blue. Properties, Methods, and Events 8.3.5.2 This section provides an alphabetical list of all properties, methods, and events of the sock object. .Acceptbcast Property For the currently selected socket (selection is made...
  • Page 344: Bcast R/O Property

    (sock.state one of PL_SST_CLOSED states). This method will be ignored when called from within an HTML page. HTML sockets are handled automatically and your application is not at freedom to close HTML ©2000-2008 Tibbo Technology Inc.
  • Page 345: Cmdbuffrq Method

    TIDE and Tibbo BASIC User Manual sockets arbitrarily. .Cmdbuffrq Method For the selected socket (selection is made through sock. Function: ) pre-requests "numpages" number of buffer pages (1 page= 256 bytes) for the CMD buffer of the socket. sock.cmdbuffrq(numpages as byte) as byte...
  • Page 346: Connect Method

    (in the same way as if the sock.reset method was used). Connection timeout of 0 means "no timeout". Actual time elapsed since the last data exchange across the socket can be obtained through the sock.toutcounter R/O property. ©2000-2008 Tibbo Technology Inc.
  • Page 347: Currentinterface R/O Property

    TIDE and Tibbo BASIC User Manual .Currentinterface R/O Property For the currently selected socket (selection is made Function: through sock.num ) returns the network interface this socket is currently communicating through. Enum (pl_sock_interfaces, byte) Type: Platform-specific. See the list of pl_sock_interfaces Value Range: constants in the platform specifications.
  • Page 348: Escchar Property

    .Eventsimple R/O Property (Obsolete) This property is no longer available. Instead, the on_sock_event property has a newstatesimple argument that carries the simplified state of the socket at the time of event generation. ©2000-2008 Tibbo Technology Inc.
  • Page 349: Getdata Method

    TIDE and Tibbo BASIC User Manual .Getdata Method For the selected socket (selection is made through sock. Function: ) returns the string that contains the data extracted from the RX buffer. ser.getdata(maxinplen as word) as string Syntax: String containing data extracted from the RX buffer...
  • Page 350: Getinband Method

    ) specifies whether this socket is in the HTTP mode. Enum (no_yes, byte) Type: 0- NO (default): "regular" TCP connection. Value Range: 1- YES: - HTTP connection. See Also: Details This property is irrelavant when the sock.protocol = PL_SOCK_PROTOCOL_UDP ©2000-2008 Tibbo Technology Inc.
  • Page 351: Httpnoclose Property

    TIDE and Tibbo BASIC User Manual (UDP). If you do not set this property directly, it's value will be: 0- NO: for all outgoing connections (active opens) of the socket. 0- NO: for incoming connections received on one of the ports from the sock.
  • Page 352: Httprqstring R/O Property

    VAR buffer, the execution of the HTTP request will be stalled indefinitely. To avoid this, reply on the on_sock_postdata even and the sock.gethttprqstring method, as explained in Complex Case (Large Amount of Variable Data) ©2000-2008 Tibbo Technology Inc.
  • Page 353: Inbandcommands Property

    TIDE and Tibbo BASIC User Manual .Inbandcommands Property For the currently selected socket (selection is made Function: through sock.num ) specifies whether inband command passing is allowed. Enum (no_yes, byte) Type: 0- NO (default): inband commands are not allowed. Value Range: 1- YES: inband commands are allowed.
  • Page 354: Inconmode Property

    (passive open) is supplied via the sock.localportlist sock.httpportlist properties. An incoming connection is accepted on any port from those two lists. The sock. localport property reflects current or the most recent local port on which connection was accepted. ©2000-2008 Tibbo Technology Inc.
  • Page 355: Localportlist Property

    TIDE and Tibbo BASIC User Manual .Localportlist Property For the currently selected socket (selection is made Function: through sock.num ) sets/returns the list of listening ports on any of which this socket will accept an incoming UDP or TCP connection.
  • Page 356: Notifysent Method

    Just like with sock.txfree , the trigger you set won't take into account any uncommitted data in the TX buffer. .Num Property Sets/returns the number of currently selected socket. Function: Byte Type: ©2000-2008 Tibbo Technology Inc.
  • Page 357: Numofsock R/O Property

    TIDE and Tibbo BASIC User Manual The value of this property won't exceed sock.numofsock Value Range: -1 (even if you attempt to set higher value). Default= 0 (socket #0 selected). See Also: Details Sockets are enumerated from 0. Most other properties and methods of this object relate to the socket selected through this property.
  • Page 358: On_Sock_Data_Arrival Event

    See Also: Details To cause generation of the on_sock_data_sent event, the application needs to use sock.notifysent each time. When the event handler is entered the sock.num automatically switched to the socket on which this event was generated. ©2000-2008 Tibbo Technology Inc.
  • Page 359: On_Sock_Event Event

    See sock.state sock.statesimple for detailed description of reported socket states. Newtate and Newstatesimple arguments of the on_sock_event have been introduced in the Tibbo Basic release 2.0. They replace sock.event sock. eventsimple R/O properties which are no longer available.
  • Page 360: On_Sock_Postdata

    VAR buffer's data. On_sock_tcp_packet_arrival Event Function: Notifies your program that the TCP packet of a certain size has arrived. Syntax: on_sock_tcp_packet_arrival(len as word) See Also: "Split Packet" Mode of TCP Data Processing Part Description ©2000-2008 Tibbo Technology Inc.
  • Page 361: Protocol Property

    TIDE and Tibbo BASIC User Manual Length of the new data in the RXed TCP packet. Details This event is only generated when sock.splittcppackets = 1- YES and sock. inbandcommands = 0- DISABLED. Notice that only new data, never transmitted before, is counted.
  • Page 362: Redir Method

    Syntax: Returns 0- PL_REDIR_NONE if redirection failed or the Returns: same value as was passed in the redir argument. See Also: ©2000-2008 Tibbo Technology Inc.
  • Page 363: Remoteip R/O Property

    TIDE and Tibbo BASIC User Manual Part Description redir Platform-specific. See the list of pl_redir constants in the platform specifications. Details Data redirection (sometimes referred to as "buffer shorting") allows to arrange efficient data exchange between ports, sockets, etc. in cases where no data alteration or parsing is necessary, while achieving maximum possible throughput is important.
  • Page 364: Remotemac R/O Property

    .Reset Method For the selected socket (selection is made through sock. Function: ) causes the socket to abort the connection with the other host. ©2000-2008 Tibbo Technology Inc.
  • Page 365: Rplbuffrq Method

    TIDE and Tibbo BASIC User Manual sock.reset Syntax: Returns: sock.close See Also: Details For TCP connections that were established, being opened, or being closed this will be a reset (RST will be sent to the other end of the connection). If connection was in the ARP phase or the transport protocol was UDP (sock.protocol...
  • Page 366: Rplfree R/O Property

    "numpages" number of buffer pages (1 page= 256 bytes) for the RX buffer of the socket. sock.rxbuffrq(numpages as byte) as byte Syntax: Actual number of pages that can be allocated (Byte). Returns: sock.txbuffrq See Also: ©2000-2008 Tibbo Technology Inc.
  • Page 367: Rxbuffsize R/O Property

    TIDE and Tibbo BASIC User Manual Part Description numpages Requested numbers of buffer pages to allocate. Details Returns actual number of pages that can be allocated. Actual allocation happens when the sys.buffalloc method is used. The socket is unable to RX data if its RX buffer has 0 capacity.
  • Page 368: Rxpacketlen R/O Property

    If, during the on_sock_data_arrival event handler execution, not all data is extracted from the RX buffer, another on_sock_data_arrival event is generated ©2000-2008 Tibbo Technology Inc.
  • Page 369: Send Method

    TIDE and Tibbo BASIC User Manual immediately after the on_sock_data_arrival event handler is exited. .Send Method For the selected socket (selection is made through sock. Function: ) commits (allows sending) the data that was previously saved into the TX buffer using the sock.setdata...
  • Page 370: Setsendinband Method

    No data will be reaching its destination even in case of buffer redirection Inband commands , however, will still be extracted from the incoming data stream and processed. Sock.connectiontout sock.toutcounter will work correctly as well. ©2000-2008 Tibbo Technology Inc.
  • Page 371: Splittcppackets Property

    TIDE and Tibbo BASIC User Manual .Splittcppackets Property For the currently selected socket (selection is made Function: through sock.num ) specifies whether the program will have additional control over the size of TCP packets being received and transmitted. Enum (no_yes, byte)
  • Page 372 Platforms Enum (pl_sock_state, byte) Type: ©2000-2008 Tibbo Technology Inc.
  • Page 373 TIDE and Tibbo BASIC User Manual 0- PL_SST_CLOSED (default): Connection is closed (and Value Range: haven't been opened yet, it is a post-powerup state). Applied both to UDP and TCP. 1- PL_SST_CL_PCLOSED: Connection is closed (it was a passive close). Applies only to TCP.
  • Page 374: Statesimple R/O Property

    This property tells the current "simplified" state of the socket, as opposed to the sock.eventsimple property that returns the "simplified" state at the moment of on_sock_event event generation. Another set of read-only properties- sock.event sock.state - return "detailed" socket states. ©2000-2008 Tibbo Technology Inc.
  • Page 375: Targetbcast Property

    TIDE and Tibbo BASIC User Manual .Targetbcast Property For the currently selected socket (selection is made Function: through sock.num ) specifies whether this port will be sending its outgoing UDP datagrams as link-level broadcasts. Enum (no_yes, byte) Type: 0- NO: UDP datagrams will be sent as "normal" packets...
  • Page 376: Targetport Property

    For the currently selected socket (selection is made Function: through sock.num ) returns the time, in 0.5 second intervals, elapsed since the data was last send or received on this socket. Word Type: 0-65535, default= 0 Value Range: ©2000-2008 Tibbo Technology Inc.
  • Page 377: Tx2Buffrq Method

    TIDE and Tibbo BASIC User Manual See Also: Closing Connections Details This property is reset to 0 each time there is some data exchanged across the socket connection. The property increments at 0.5 second intervals while no data is moving through this socket.
  • Page 378: Tx2Len R/O Property

    Buffer allocation will not work if the socket port to which this buffer belongs is not idle (sock.statesimple is not at 0- PL_SSTS_CLOSED) at the time when sys. buffalloc executes. You can only change buffer sizes of sockets that are idle. ©2000-2008 Tibbo Technology Inc.
  • Page 379: Txbuffsize R/O Property

    TIDE and Tibbo BASIC User Manual .Txbuffsize R/O Property For the currently selected socket (selection is made Function: through sock.num ) returns current TX buffer capacity in bytes. Word Type: 0-65535, default= 0 (0 bytes). Value Range: See Also: Details Buffer capacity can be changed through the sock.txbuffrq...
  • Page 380: Txlen R/O Property

    "pix1.html", but only if the file "pix1.bmp" is not found. Data output by the webserver to the browser will still look like a ".bmp" file. For this to work, the "pix1.html" must exist in the project. ©2000-2008 Tibbo Technology Inc.
  • Page 381: Varbuffrq Method

    TIDE and Tibbo BASIC User Manual This property allows programmatic generation of non-HTML files. In the above example it is possible to generate the BMP file through a BASIC code. There is no other way to do this, since only HTML files are parsed for BASIC code inclusions.
  • Page 382: Line/Port Manipulation With Pre-Selection

    'now set this line to LOW io.enabled=NO 'configure the line as input now x=io.state 'read the state of the line Same can be done with ports -- use io.portnum io.portstate , and portenabled properties to achieve this: ©2000-2008 Tibbo Technology Inc.
  • Page 383: Line/Port Manipulation Without Pre-Selection

    TIDE and Tibbo BASIC User Manual io.portnum=2 'select port #2 io.portenabled=&hFF 'this means that every port line's output buffer will be enabled (&hFF=&b11111111) 'output &h55: port lines 0, 2, 4, and 6 will be at HIGH, 4 remaining lines will be at LOW (&h55=&b01010101) io.portstate=&h55...
  • Page 384: Controlling Output Buffers

    I/O lines it uses cannot (should not) be manipulated though the io object. Controlling Output Buffers As far as the I/O line/port control goes, there are two kinds of Tibbo devices and corresponding platforms -- those without output buffer control, and those with output buffer control.
  • Page 385: Working With Interrupts

    TIDE and Tibbo BASIC User Manual uses may be configured for input or output automatically. For such lines, when the corresponding special function block is disabled, the state of the output buffer is restored automatically to what it used to be prior to enabling this function block.
  • Page 386: Properties, Events, Methods

    1- YES: the interrupt line is enabled See Also: Working With Interrupts Details Change of state of any enabled interrupt line leads to the on_int_ev event generation. State change of disabled interrupt lines produces no effect. ©2000-2008 Tibbo Technology Inc.
  • Page 387: Intnum Property

    TIDE and Tibbo BASIC User Manual .Intnum Property Sets/returns the number of currently selected interrupt Function: line. Enum (pl_int_num, byte) Type: Platform-specific. See the list of pl_int_num constants in Value Range: the platform specifications. See Also: Working With Interrupts Details Selected interrupt line can be enabled or disabled using the io.intenabled...
  • Page 388: Lineset Method

    Details Selects a particular I/O line to be manipulated through the io.state io.enabled properties (the latter may or not be available on your platform). The list of available I/O lines is defined by the pl_io_num constant. ©2000-2008 Tibbo Technology Inc.
  • Page 389: On_Io_Int Event

    TIDE and Tibbo BASIC User Manual On_io_int Event Function: Generated when the change of state on one of the enabled interrupt lines is detected. Declaration: on_io_int(linestate as byte) See Also: Working With Interrupts Part Description linestate 0-255. Each bit of this value corresponds to one interrupt line in the order that these lines are declared in the pl_int_num enum.
  • Page 390: Portnum Property

    Line/Port Manipulation Without Pre-selection See Also: portget Part Description Platform-specific. See the list of pl_io_port_num constants in the platform specifications. state 0-255. Each bit of this value corresponds to one member I/ O line of the 8-bit port. Details ©2000-2008 Tibbo Technology Inc.
  • Page 391: Portstate Property

    TIDE and Tibbo BASIC User Manual No line pre-selection with the io.portnum property is required and the value of the io.portnum will not be changed. .Portstate property Sets/returns the state of the currently selected I/O port Function: (selection is made through the io.portnum...
  • Page 392 Each line of the file describes the setting name, minimum value (length), maximum value (length), and default value. Now, supposing you need to extract the string describing the "Port" setting. Here is the code: ©2000-2008 Tibbo Technology Inc.
  • Page 393: Find Method

    TIDE and Tibbo BASIC User Manual as word as string romfile.open("settings.txt") romfile.size=0 then 'File does not exist! Do something about it! end if 'look for the 'port' substring w=romfile.find(1,"Port",1) then 'Line not found- do something about it! end if romfile.pointer=w...
  • Page 394: Getdata Method

    The property has no other uses. This property is not available on the EM200/200, DS202 platform. ©2000-2008 Tibbo Technology Inc.
  • Page 395: Open Method

    TIDE and Tibbo BASIC User Manual .Open Method 8.3.7.4 Opens or re-opens a resource (ROM) file. Function: romfile.open(byref filename as string) Syntax: Returns: Romfile Object, romfile.size See Also: Part Description filename Name of the ROM file to open. Details Only one ROM file can be opened at any given time. If the file exists and is not empty the romfile.pointer...
  • Page 396: Stor Object

    Special configuration area The EEPROM IC of the device is also used to store certain configuration information required by the device (for details see "Platform-dependent Programming Information" topic inside your platform specifications section). Memory available to ©2000-2008 Tibbo Technology Inc.
  • Page 397: Base Property

    TIDE and Tibbo BASIC User Manual your application equals the capacity of the IC minus the size of the special configuration area. By default, when you access the first byte of the EEPROM you are actually accessing the first memory location above the special configuration area. One property -- stor.base...
  • Page 398: Setdata Method (Previously .Set)

    Programming Information" topic inside your platform specifications section). By setting the stor.base to 1 you are allowing access to the special configuration area. With Tibbo Basic release V2, this method had to be renamed from .get to .getdata. This is because the period (".") separating "stor" from "getdata"...
  • Page 399: Size R/O Property

    Programming Information" topic inside your platform specifications section). By setting the stor.base to 1 you are allowing access to the special configuration area. With Tibbo Basic release V2, this method had to be renamed from .set to .setdata. This is because the period (".") separating "stor" from "setdata"...
  • Page 400: Pat Object

    LEDs that are present on all external devices, boards, and some modules offered by Tibbo. All modules have SG and SR I/O lines that are meant for controlling external status LEDs. Note that when the Tibbo BASIC application is not...
  • Page 401: Channel Property

    For channel 0, reading the property always returns (-1), and writing has no effect. All other channels use regular I/O lines of Tibbo devices. Any I/O line can be selected to be the green control line of the selected channel. By default, all control lines are mapped to the non-existent line PL_IO_NULL.
  • Page 402: On_Pat Event

    You can use this symbol twice to x4 speed. Adding even more '*' will not have any effect. patint Defines whether the pat.play method is allowed to interrupt another pattern that is already playing: 0- PL_PAT_NOINT: cannot interrupt 1- PL_PAT_CANINT: can interrupt) Details ©2000-2008 Tibbo Technology Inc.
  • Page 403: Redmap Property

    For channel 0, reading the property always returns (-1), and writing has no effect. All other channels use regular I/O lines of Tibbo devices. Any I/O line can be selected to be the red control line of the selected channel. By default, all control lines are mapped to the non-existent line PL_IO_NULL.
  • Page 404: Divider Property

    Most low-cost buzzers have resonant frequency at which they emit the loudest sound. Check the specifications for your buzzer and set the divider accordingly. On_beep Event 8.3.10.2 Function: Generated when buzzer pattern finishes "playing". Declaration: on_beep See Also: Beep Object beep.play ©2000-2008 Tibbo Technology Inc.
  • Page 405: Play Method

    TIDE and Tibbo BASIC User Manual Details This can only happen for "non-looped" patterns. Multiple on_beep events may be waiting in the event queue. .Play Method 8.3.10.3 Loads new beeper pattern to play. Function: pat.play(byref pattern as string, patint as...
  • Page 406: Getdata Method (Previously .Get)

    Number of elapsed days, minutes, and seconds. Notice Returns: that this is done indirectly, through byref arguments. RTC Object See Also: Part Description daycount Number of elapsed days. mincount Number of elapsed minutes. seconds Number of elapsed seconds. ©2000-2008 Tibbo Technology Inc.
  • Page 407: Running R/O Property

    It is not necessary to use rtc.set if the backup power was present while the device was off. With Tibbo Basic release V2, this method had to be renamed from .get to .getdata. This is because the period (".") separating "rtc" from "getdata"...
  • Page 408: Lcd Object

    It is not necessary to use rtc.set if the backup power was present at all times while the device was off. With Tibbo Basic release V2, this method had to be renamed from .get to .getdata. This is because the period (".") separating "stor" from "setdata"...
  • Page 409: Overview

     Supported Controllers/Panels  Understanging Controller Properties Display panels come in all types, shapes, and sizes. Tibbo supports a limited but growing number of controllers/panels . Each supported controller requires its own "mini-driver". Your application cannot specify the desired controller. Instead, controller type is selected through the Customize Platform dialog, accessible through the Project Settings dialog.
  • Page 410 You can use this detailed information to select color values that will work correctly on all color displays, even those you haven't tested yet. Here is a useful example where you work out three constants -- color_red, color_green, and color_blue -- that will universally work for any color display. ©2000-2008 Tibbo Technology Inc.
  • Page 411: Preparing The Display For Operation

    TIDE and Tibbo BASIC User Manual color_red, color_green, color_blue As word lcd_red=val("&b"+strgen(lcd.redbits/&hFF,"1")+strgen(lcd.redbits &hFF,"0")) lcd_green=val("&b"+strgen(lcd.greenbits/&hFF,"1")+strgen(lcd.greenbits &hFF,"0")) lcd_blue=val("&b"+strgen(lcd.bluebits/&hFF,"1")+strgen(lcd.bluebits &hFF,"0")) Now you can scientifically work out the constant for the white color: lcd_white=lcd_red+lcd_green+lcd_blue In reality, you don't have to bother calculating color_white like this.
  • Page 412: Lines, Rectangles, And Fills

    "off" dot is displayed in backcolor. The following two sections -- Lines, Rectangles, and Fills , and Working With Text -- discuss the above methods in more details. Lines, Rectangles, and Fills Lines ©2000-2008 Tibbo Technology Inc.
  • Page 413: Working With Text

    TIDE and Tibbo BASIC User Manual lcd.line method draws a line between any points. Lcd.verline lcd. horline draw vertical and horizontal lines correspondingly. Use the last two methods whenever possible because they work faster than generic lcd.line. The line is drawn using the color set in the lcd.forecolor...
  • Page 414 "aligned". It will also work if you select a font which is "perpendicular" to your display, but text printing might slow down considerably. We typically offer two versions for each font, for example, "Tibbo-5x7(V).bin" and "Tibbo-5x7(H)". V stands for "vertical" and "H" stands "horizontal".
  • Page 415 TIDE and Tibbo BASIC User Manual text horizontally (remember, text height is equal to lcd.fontheight ). In the following example, we align the text output along the right side of the screen. This requires us to know how wide this output will be: x=lcd.getprintwidth("Text")
  • Page 416: Raster Font File Format

    This topic details font file format used by the LCD object. The font file is a resource file that is added to your Tibbo Basic project. Like all other resource files "attached" to your project, font files are accessible through the romfile object.
  • Page 417 TIDE and Tibbo BASIC User Manual Contains various information such as the total number of characters in this font, character height, etc. Also contains Header the number of code groups in the code groups table (see below). Contains descriptors of "code groups". Each code group...
  • Page 418 Depending on the pixels_per_byte field of the header, each byte of data may encode just one or several pixels. Additionally, when using more than 1 pixel-per- ©2000-2008 Tibbo Technology Inc.
  • Page 419 TIDE and Tibbo BASIC User Manual byte encoding, the orientation field of the header defines whether pixels are combined horizontally or vertically. The drawings below illustrate how character bitmaps are stored in the font file. As an example, characters of 10x14 size (in pixels) are used. Drawing A is for one pixel/byte encoding, drawing B -- for 8 pixels/byte with vertical orientation, C -- for 8 pixels/byte with horizontal orientation.
  • Page 420: Displaying Images

    For example, if your project requires several icons you can put them all into a single "strip". This improves performance because you don't have to open a separate file to display each icon: ©2000-2008 Tibbo Technology Inc.
  • Page 421: Improving Graphical Performance

    TIDE and Tibbo BASIC User Manual romfile.open("icon_strip.bmp") lcd.bmp(romfile.offset,0,0,11,0,11,11) 'display the second icon (right arrow) Note that only 2-, 16-, and 256-color modes are currently supported and the lcd. bmp will return 1- NG if you try to display any other type of BMP file. Compressed BMP files will be rejected too.
  • Page 422 You can place lcd.lock before the block of code that changes display data, and put lcd.unlock at the end of this code block: s1=str(dw1*100/200) s2=str(dw2*100/200) lcd.lock 'lock the display lcd.print(s1,0,0) lcd.print(s2,0,10) lcd.unlock 'unlock the display Display-related code is often nested, with one procedure calling another, and so ©2000-2008 Tibbo Technology Inc.
  • Page 423 TIDE and Tibbo BASIC User Manual on. If you are using display locking, you should ideally place locks/unlocks in each related routine. A complication arises with regards to when to unlock the display. For example, supposing you have two subs: lcd_sub1 and lcd_sub2: 'some main routine that invokes lcd_sub1 and lcd_sub2 ..
  • Page 424: Supported Controllers/Panels

     Himax HX8309 (Ampire AM176220)  None of the above suits your project's needs? Tibbo can be contracted to develop a driver for another display you want to use. We offer reasonable development prices and ZNR (zero non-refundable) payment scheme, in which your initial payment for the driver development is gradually returned to you as you purchase Tibbo hardware.
  • Page 425 TIDE and Tibbo BASIC User Manual I/O line numbers are from the pl_io_num enum. Port number is from the pl_io_port_num enum. Line and port numbers are platform-specific. See the list of pl_io_num and pl_io_port_num constants in the platform specifications. For the TEV-LB0 board, the lcd.iomapping property should be set to "44,46,40,41,43,42,4".
  • Page 426: Solomon Ssd1329 (Ritdisplay Rgs13128096)

    6. Number of the I/O port connected to D7-0. I/O line numbers are from the pl_io_num enum. Port number is from the pl_io_port_num enum. Line and port numbers are platform-specific. See the list of pl_io_num and pl_io_port_num constants in your platform specifications. ©2000-2008 Tibbo Technology Inc.
  • Page 427: Himax Hx8309 (Ampire Am176220)

    TIDE and Tibbo BASIC User Manual For the TEV-LB0 board, lcd.iomapping should be set to "44,43,42,41,40,4". Code example -- TEV-LB1 This code will properly setup and enable this controller/panel (we assume that the testing is done using the TEV-LB1 board): lcd.iomapping="44,43,42,41,40,4"...
  • Page 428: Properties And Methods

    The following classification groups properties and methods of the lcd. object by their logical function. LCD panel characteristics: lcd.paneltype [R/O Property]  lcd.pixelpacking [R/O Property]  lcd.bitsperpixel [R/O Property]  lcd.redbits [R/O Property]  lcd.greenbits [R/O Property]  ©2000-2008 Tibbo Technology Inc.
  • Page 429 TIDE and Tibbo BASIC User Manual lcd.bluebits [R/O Property]  Preparing to work: lcd.iomapping [Property]  lcd.width [Property]  lcd.height [Property]  lcd.inverted [Property]  lcd.rotated [Property]  lcd.enabled [Property]  Graphical operations: lcd.setpixel [Method]  lcd.forecolor [Property]  lcd.backcolor [Property] ...
  • Page 430: Backcolor Property

    For color panels, this property reflects the combined number of red, green, and blue bits available for each pixel (see lcd.redbits lcd.greenbits , and lcd.bluebits The number of bits per pixel affects how lcd.forecolor lcd.backcolor , and lcd.setpixel are interpreted. Also, the output produced by lcd.bmp depends ©2000-2008 Tibbo Technology Inc.
  • Page 431: Bluebits R/O Property

    TIDE and Tibbo BASIC User Manual on this property. .Bluebits R/O Property A 16-bit value packing two 8-bit parameters: number of Function: "blue" bits per pixel (high byte) and the position of the least significant blue bit within the color word (low byte).
  • Page 432: Enabled Property

    Details Several properties -- lcd.iomapping lcd.width lcd.height lcd.inverted lcd.rotated -- can only be changed when the display panel is disabled. When you set this property to 1- YES, the controller of the panel is initialized and ©2000-2008 Tibbo Technology Inc.
  • Page 433: Error R/O Property

    TIDE and Tibbo BASIC User Manual enabled. This will only work if your display is properly connected, correct display type is selected in your project, lcd.iomapping is set property, and necessary I/O lines are configured as outputs. The lcd.error R/O property will indicate 1- YES if there was a problem enabling the display.
  • Page 434: Filledrectangle Method

    Returns the maximum height, in pixels, of characters in Function: the currently selected font. Byte Type: 0-255. Default= 0. Value Range: See Also: Working With Text lcd.fontpixelpacking Details This property will only return meaningful data after you select a font using the lcd.setfont method. ©2000-2008 Tibbo Technology Inc.
  • Page 435: Fontpixelpacking R/O Property

    TIDE and Tibbo BASIC User Manual .Fontpixelpacking R/O Property Indicates how pixels are packed into bytes in a currently Function: selected font. Enum (ver_hor, byte) Type: 0- PL_VERTICAL: Several vertically adjacent pixels are Value Range: packed into each byte of character bitmaps.
  • Page 436: Getprintwidth Method

    This property also tells you the bit position and length of the green field in values used by lcd.forecolor lcd.backcolor , and lcd.setpixel . If, for example, the lcd.redbits =&h0500, lcd.bluebits =&h0605, and lcd.greenbits=&h050B, then you can reconstruct the composition of the red, green, and blue bits in a word: bit ©2000-2008 Tibbo Technology Inc.
  • Page 437: Height Property

    TIDE and Tibbo BASIC User Manual 15 -> gggggbbbbbbrrrrr <- bit 0. In this example, the green field is the last field and occupies 5 bits (15-11). .Height Property Sets the vertical resolution of the display panel in pixels. Function:...
  • Page 438: Inverted Property

    Supported Controllers section for details. This property can only be changed when the display is disabled (lcd.enabled 0- NO). .Line Method Draws a line. Function: lcd.line(x1 as word,y1 as word, x2 as word, y2 as Syntax: word) ©2000-2008 Tibbo Technology Inc.
  • Page 439: Linewidth Property

    TIDE and Tibbo BASIC User Manual Returns: Lines, Rectangles, and Fills lcd.rectangle lcd. See Also: filledrectangle lcd.fill Description X coordinate of the first point. Value range is 0 to lcd.width Y coordinate of the first point. Value range is 0 to lcd.height...
  • Page 440: Lockcount R/O Property

    .Paneltype R/O Property Returns the type of the currently selected controller/ Function: panel. Enum (pl_lcd_paneltype, byte) Type: 0- PL_LCD_PANELTYPE_GRAYSCALE: This is a Value Range: monochrome or grayscale panel/controller. 1- PL_LCD_PANELTYPE_COLOR: This is a color panel/ controller. ©2000-2008 Tibbo Technology Inc.
  • Page 441: Pixelpacking R/O Property

    TIDE and Tibbo BASIC User Manual See Also: Understanding Controller Properties Working With Pixels and Colors Details Controller/panel selection is made through the Customize Platform dialog, accessible through the Project Settings dialog. Monochrome panels/controllers only allow you to turn pixels on and off. Grayscale panels/controllers allow you to set the brightness of pixels in steps.
  • Page 442: Printaligned Method

    X coordinate of the top-left point of the print area. Value range is 0 to lcd.width Y coordinate of the top-left point of the print area. Value range is 0 to lcd. height Width of the print area in pixels. Height of the print area in pixels. Details ©2000-2008 Tibbo Technology Inc.
  • Page 443: Rectangle Method

    TIDE and Tibbo BASIC User Manual For this method to work, a font must first be selected with the lcd.setfont method. The lcd.textalignment lcd.textorientation lcd.texthorizontalspacing , and lcd.textverticalspacing properties will affect how the text is printed. This method breaks the text into lines to stay within the specified rectangular output area.
  • Page 444: Rotated Property

    0- OK: The font was found and the data appears to be Returns: valid. 1- NG: There is no valid font data at specified offset. Working with Text See Also: Description offs Offset within the compiled binary of your application at which the font file is stored. ©2000-2008 Tibbo Technology Inc.
  • Page 445: Setpixel Method

    TIDE and Tibbo BASIC User Manual Details A valid font file must be selected before you can use the lcd.print lcd. printaligned , or lcd.getprintwidth methods. Naturally, the font file must be present in your project for this to work (see how to a font file).
  • Page 446: Texthorizontalspacing Property

    0- 255. Default= 1 (1 pixel). Value Range: See Also: Working With Text lcd.textalignment lcd.textorientation lcd.textverticalspacing Details .Textorientation Property Specifies the print angle for text output produced by the Function: lcd.print lcd.printaligned methods. Enum (pl_lcd_text_orientation, byte) Type: ©2000-2008 Tibbo Technology Inc.
  • Page 447: Textverticalspacing Property

    TIDE and Tibbo BASIC User Manual 0- PL_LCD_TEXT_ORIENTATION_0: At 0 degrees Value Range: (default). 1- PL_LCD_TEXT_ORIENTATION_90: At 90 degrees. 2- PL_LCD_TEXT_ORIENTATION_180: At 180 degrees. 3- PL_LCD_TEXT_ORIENTATION_270: At 270 degrees. See Also: Working With Text lcd.textalignment lcd.texthorizontalspacing lcd.textverticalspacing Details .Textverticalspacing Property...
  • Page 448: Verline Method

    "part" of the controller may be utilized. This property can only be changed when the display is disabled (lcd.enabled ©2000-2008 Tibbo Technology Inc.
  • Page 449: Fd Object

    Your flash memory's primary use is to store the firmware of your device, as well as compiled Tibbo Basic application. The firmware/ application typically occupy only a part of the flash memory. Available space will be referred to as the "data area"...
  • Page 450: Sharing Flash Between Your Application And Data

    The .fd object uses the same physical flash chip that stores the firmware of your device, as well as your Tibbo Basic application. The flash memory consists of 264- byte sectors. It is customary to use 256 bytes of each sector to store actual data, and reserve the rest for "service"...
  • Page 451: Fd. Object's Status Codes

    This approach was chosen to minimize the influence of the changing size of your Tibbo Basic application on the data you keep in the flash memory. Typically, the size of your application keeps changing as you develop and debug it. At the same time, you often need to keep certain data in the data area permanently, and don't want to recreate this data every time you load new iteration of your application.
  • Page 452: File-Based Access

    "housekeeping" area of the disk. This consists of two boot sectors plus a certain number of sectors for the file record table (FRT) and the file allocation table (FAT). For the exact numbers see Disk Area Allocation Details ©2000-2008 Tibbo Technology Inc.
  • Page 453: Disk Area Allocation Details

    TIDE and Tibbo BASIC User Manual Formatting is performed using the fd.format method. This method accepts, as arguments, two parameters: total number of sectors occupied by the disk, and the maximum number of files that you wish to be able to store on the disk.
  • Page 454 This is less than the minimal 16 FAT sectors that are always provided, so the fd. object will still allocate 16 sectors. Allocation and capacity calculation example The fd.format method takes, as an input parameter, the total number of sectors ©2000-2008 Tibbo Technology Inc.
  • Page 455: Mounting The Flash Disk

    TIDE and Tibbo BASIC User Manual that you wish the disk to occupy. From that, and the supplied desired max number of files, the fd.format will work out the size of each area of the disk. Let's see this on a real example: Supposing, you call fd.format(1300,41) -- you want the disk to occupy 1300 sectors and store 41 file.
  • Page 456: File Names And Attributes

    Here is an example where we create a file and set its attributes too: fd.create("File1.dat R 25-JUL-2008") ' <File1.dat> is the file name, <R 25-JUL-2008> -- attributes, it is up to our program how to interpret this! ©2000-2008 Tibbo Technology Inc.
  • Page 457: Checking Disk Vitals

    TIDE and Tibbo BASIC User Manual Checking Disk Vitals Once the disk is mounted , you can check several important flash disk parameters: Fd.capacity will tell you the number of usable data sectors on the disk  (reminder: each sector stores 256 bytes of data).
  • Page 458: Reading And Writing File Attributes

    At times it is necessary to get the list of all files stored on the flash disk. Most operating systems provide this feature in the form of a DIR command. The fd. object offers two methods -- fd.resetdirpointer fd.getnextdirmember that allow you to get the names of all stored files one by one. ©2000-2008 Tibbo Technology Inc.
  • Page 459: Opening Files

    The concept of file numbers is not new -- other operating systems, too, assign a number to the file when the file is opened. In Tibbo Basic, you select the number you want to open the file on yourself. You do this by selecting a desired value for the fd.filenum property:...
  • Page 460: Writing To And Reading From Files

    -- at offset two, and so on. The very last byte in the file is at offset equal to the size of the file, which is indicated by the fd.filesize R/O property. The maximum pointer value, however, ©2000-2008 Tibbo Technology Inc.
  • Page 461: Removing Data From Files

    TIDE and Tibbo BASIC User Manual is fd.filesize+1! When the pointer is at maximum, it effectively points at the file position that doesn't exist yet. So, writing to the file at this position will append new data to the end of the file. Writing to the file when the pointer is not at maximum will overwrite existing data.
  • Page 462: Searching Files

    The increment parameter is very important as it allows you to perform two fundamentally different classes of search. Full text search Set the increment to 1 and you will search through the entire contents of the file: ©2000-2008 Tibbo Technology Inc.
  • Page 463 TIDE and Tibbo BASIC User Manual As dword 'try to find the 2nd occurrence of 'ABC', search forward starting at the beginning of the file dw=fd.find(1,"ABC",2,FORWARD,1) fd.laststatus<>PL_FD_STATUS_OK Then 'some disk-related error Else dw<>0 Then 'found! process this... Else 'not found...
  • Page 464: Closing Files

    264-byte RAM buffers numbered #0 and #1 (each flash sector contains 264 bytes of data). The fd.buffernum property selects one of the buffers as the source/destination for the data (see the drawing below). ©2000-2008 Tibbo Technology Inc.
  • Page 465 TIDE and Tibbo BASIC User Manual Reading data from a sector is a two-step process. First, you use fd.getsector load all 264 bytes from desired sector into the currently selected RAM buffer. Next, you use fd.getbuffer to read the data from the selected buffer. This method...
  • Page 466: Using Checksums

    256-byte data block plus the checksum itself should be zero. Of course, this is an arbitrary choice -- there is no special reason why the .fd object does it this way, and not in any other way. We just decided to do it like that, and that was it! ©2000-2008 Tibbo Technology Inc.
  • Page 467 TIDE and Tibbo BASIC User Manual 16-bit values for these calculations are little-endian. That is, offset 0 of the sector is presumed to be the high byte of the first 16-bit value, offset 1 -- low byte of the first 16-bit value, offset 2 -- high byte of the second 16-bit value, and so on.
  • Page 468: Upgrading The Firmware/Application

    As was explained under Direct Sector Access , you can't use fd.setsector write to the flash area occupied by the firmware and Tibbo Basic application. This is done to prevent your application from inadvertently damaging its own code or the firmware. A special fd.copyfirmware...
  • Page 469: File-Based And Direct Sector Access Coexistence

    TIDE and Tibbo BASIC User Manual File-based and Direct Sector Access Coexistence File-based direct sector access methods can be used at the same time, as long as you understand how direct access may affect (and possibly screw up) the flash disk.
  • Page 470: Ensuring Disk Data Integrity

    Maintaining the data integrity is a very important task, and the one where the flash memory needs a lot of help from your smart Tibbo Basic application. The biggest source of potential trouble is a sudden loss of power right in the middle of writing to the flash IC.
  • Page 471 TIDE and Tibbo BASIC User Manual losing the old and the new contents of the sector.  For many flash disk operations , a single operation requires making changes to several sectors. For example, creating a file requires to change data both in the file record table (FRT) and the file allocation table (FAT).
  • Page 472: Properties And Methods

    [R/O Property]  fd.maxopenedfiles [R/O Property]  fd.format [Method, D, S]  fd.mount [Method, S]  fd.numservicesectors [R/O Property, M]  fd.capacity [R/O Property, M]  fd.totalsize [R/O Property, M]  fd.getfreespace [Method, M-S]  ©2000-2008 Tibbo Technology Inc.
  • Page 473: Availableflashspace R/O Property

    TIDE and Tibbo BASIC User Manual fd.laststatus [R/O Property]  fd.ready [R/O Property]  Directory-related: fd.maxstoredfiles [R/O Property, M]  fd.getnumfiles [Method, M-S]  fd.resetdirpointer [Method]  fd.getnextdirmember [Method, M-S]  fd.getattributes [Method, M-S]  fd.setattributes [Method, M-S]  fd.create [Method, M-S] ...
  • Page 474: Buffernum Property

    Platforms Details The value of this property reflects free flash space not occupied by currently loaded Tibbo Basic application. You may use the fd.format method to create the flash disk as large as available flash space. Note that the actual capacity of the disk (fd.capacity...
  • Page 475: Checksum Method

    TIDE and Tibbo BASIC User Manual The disk must be mounted (see fd.mount ) for this property to return a meaningful value. .Checksum Method Calculates or verifies the checksum for the data in the Function: currently selected RAM buffer of the flash memory (selection is made through the fd.buffernum...
  • Page 476: Close Method

    Number of sectors to copy. sect Details This method allows you to remotely upgrade the firmware and the Tibbo Basic application of your device. First, your application can receive and store the new firmware into the unused area of the flash memory (see fd.availableflashspace...
  • Page 477: Cutfromtop Method

    TIDE and Tibbo BASIC User Manual You will need to physically go to your device and upload correct firmware through its serial port. .Cutfromtop Method Removes a specified number of sectors from the Function: beginning of a file opened "on" a currently selected file number (selection is made through the fd.filenum...
  • Page 478: Create Method

    (see fd.format ) and can be checked through the maxstoredfiles R/O property. Attempting to create another file when the maximum number of stored files has already been reached will result in the 6- PL_FD_STATUS_FILE_TABLE_FULL status code. ©2000-2008 Tibbo Technology Inc.
  • Page 479: Delete Method

    TIDE and Tibbo BASIC User Manual Each file always occupies at least one sector in the data area of the disk. The first sector is allocated when you invoke the fd.create method. This is why an attempt to create a new file may result in the 7- PL_FD_STATUS_DATA_FULL status code.
  • Page 480: Fileopened R/O Property

    ), or reducing the file size with fd.setfilesize fd.cutfromtop methods. .Find Method Finds Nth instance of data satisfying selected criteria in a Function: file opened "on" a currently selected file number (selection is made through the fd.filenum ©2000-2008 Tibbo Technology Inc.
  • Page 481 TIDE and Tibbo BASIC User Manual fd.find(frompos as dword, byref substr as string, Syntax: instance as word, dir as forward_back, incr as word, mode as pl_fd_find_modes) as dword File position (counting from one) at which the target Returns: occurrence of the substr was discovered, or 0 if the target occurrence of the substr was not found.
  • Page 482: Flush Method

    These changes will be lost if your device reboots. To prevent this, use the fd.flush method. Note that the fd.flush method does not depend on the current fd.filenum value and works globally on any most recently changed file. ©2000-2008 Tibbo Technology Inc.
  • Page 483: Format Method

    TIDE and Tibbo BASIC User Manual .Format Method Formats the flash memory to create a flash disk. Function: fd.format(totalsize as word, numstoredfiles as byte) as Syntax: pl_fd_status_codes One of the following pl_fd_status_codes , also affects Returns: fd.laststatus 0- PL_FD_STATUS_OK: Completed successfully.
  • Page 484: Getbuffer Method

    Returns: also affects the state of the fd.laststatus . The following status codes are possible: 0- PL_FD_STATUS_OK: Completed successfully. 1- PL_FD_STATUS_FAIL : Physical flash memory failure (fatal). See Also: Direct Sector Access fd.setbuffer fd.getsector fd.setsector fd.checksum ©2000-2008 Tibbo Technology Inc.
  • Page 485: Getdata Method

    TIDE and Tibbo BASIC User Manual Description offs Starting offset in the buffer. Possible value range is 0-263 (the buffer stores 264 bytes of data, offset is counted from 0). Number of bytes to read. Will be corrected downwards if necessary.
  • Page 486: Getfreespace Method

    This method returns its execution status indirectly, through the fd.laststatus R/O property. All possible error states are "generic" and are not described here. .Getnextdirmember Method Returns the next filename (if any) found in the disk Function: directory. fd.getnextdirmember() as string Syntax: ©2000-2008 Tibbo Technology Inc.
  • Page 487: Getnumfiles Method

    TIDE and Tibbo BASIC User Manual The string containing the file name of the next directory Returns: member or an empty string if all file names have already been returned. The method also affects the state of the fd.laststatus . The following status codes are possible: 0- PL_FD_STATUS_OK: Completed successfully.
  • Page 488: Getsector Method

    All status codes generated by this method are "generic" and are not described here. .Laststatus R/O Property Returns the execution result for the most recent disk- Function: related method execution. Enum (pl_fd_status_code, byte) Type: ©2000-2008 Tibbo Technology Inc.
  • Page 489: Maxopenedfiles R/O Property

    TIDE and Tibbo BASIC User Manual 0- PL_FD_STATUS_OK: Completed successfully (default) Value Range: 1- PL_FD_STATUS_FAIL : Physical flash memory failure (fatal). 2- PL_FD_STATUS_CHECKSUM_ERR: Checksum error has been detected in one of the disk sectors (fatal). 3- PL_FD_STATUS_FORMAT_ERR: Disk formatting error has been detected (fatal).
  • Page 490: Maxstoredfiles R/O Property

    This condition will be reflected by the fd.laststatus R/O property, while the fd.ready will become 0- NO. Note, that not every error indicated by the fd.laststatus is fatal. ©2000-2008 Tibbo Technology Inc.
  • Page 491: Numservicesectors R/O Property

    TIDE and Tibbo BASIC User Manual The disk will also be dismounted if your application invokes the fd.format method or uses the fd.setsector to write to a sector belonging to a mounted flash disk (sectors 0 thru fd.totalsize -1). .Numservicesectors R/O Property...
  • Page 492: Pointer R/O Property

    Type: 0- NO: The disk is not mounted and not ready for use Value Range: (default). 1- YES: The disk is mounted and ready for use. See Also: Fd. Object's status codes Mounting the Flash Disk ©2000-2008 Tibbo Technology Inc.
  • Page 493: Rename Method

    TIDE and Tibbo BASIC User Manual Details Use the fd.mount method to mount this disk. .Rename Method Renames a file specified by its name. Function: fd.create(byref old_name as string, byref new_name Syntax: as string) as pl_fd_status_codes One of the following...
  • Page 494: Resetdirpointer Method

    .Setattributes Method Sets the attributes string for a file with the specified file Function: name. fd.setattributes(byref name as string, byref attr as Syntax: string) as pl_fd_status_codes ©2000-2008 Tibbo Technology Inc.
  • Page 495: Setbuffer Method

    TIDE and Tibbo BASIC User Manual One of the following pl_fd_status_codes , also affects Returns: fd.laststatus 0- PL_FD_STATUS_OK: Completed successfully. 1- PL_FD_STATUS_FAIL : Physical flash memory failure (fatal). 2- PL_FD_STATUS_CHECKSUM_ERR: Checksum error has been detected in one of the disk sectors (fatal).
  • Page 496: Setdata Method

    10- PL_FD_STATUS_NOT_OPENED: No file is currently opened on the current value of the fd.filenum property. Writing To and Reading From Files fd.getdata See Also: fd.sector Description A string containing data to be written to the file. ©2000-2008 Tibbo Technology Inc.
  • Page 497: Setfilesize Method

    TIDE and Tibbo BASIC User Manual Details As a result of this method invocation, the pointer (see fd.pointer ) will be advanced forward by the number of bytes written to the file. If the pointer wasn't at the end of the file (at fd.filesize...
  • Page 498: Setpointer Method

    (that is, fd.pointer > fd.filesize+1) then the pointer will be set to fd.filesize+1. Current pointer position can be obtained through the fd.pointer R/O property. All possible status codes returned by this method are "generic" and are not described here. ©2000-2008 Tibbo Technology Inc.
  • Page 499: Setsector Method

    You can only write to "free" flash sectors that are not occupied by the firmware or Tibbo Basic application of your device. The number of free sectors can be determined through the fd.availableflashspace R/O property. Trespassing this boundary will result in the 1- PL_FD_STATUS_FAIL status code.
  • Page 500: Kp Object

    D1-D4 are necessary and should not be omitted. For best result, use Schottky diodes -- they have low drop voltage. Pull- up resistors R1-R4 prevent the return lines from floating and should be present as well. ©2000-2008 Tibbo Technology Inc.
  • Page 501 TIDE and Tibbo BASIC User Manual On platforms with output buffer control , all intended scan lines should be configured as outputs, and all return lines -- as inputs (see io.num io.enabled Scan lines can optionally perform a double duty and drive LEDs. One such LED can be connected to each scan line, preferably through a buffer, as shown on the drawing below.
  • Page 502: Key States And Transitions

    2- PL_KP_EVENT_PRESSED: The key has been pressed (just now). 3- PL_KP_EVENT_LONGPRESSED: The key has been pressed "for a while". 4- PL_KP_EVENT_REPEATPRESSED: Auto-repeat for the key. The diagram below shows all key states and possible state transitions. ©2000-2008 Tibbo Technology Inc.
  • Page 503: Preparing The Keypad For Operation

    TIDE and Tibbo BASIC User Manual Possible state transitions are indicated by arrows. Red arrows show transitions for when the key is pressed (or remains pressed), blue -- for when the key is released (or remains released). The time it takes for the key to transition from one state to another is quantified in 10ms intervals.
  • Page 504 Notice that no matter how you set kp.scanlinesmapping and kp. returnlinesmapping, reading them will always return a simple list of numbers (shown in the example above). Defining state transition delays Your second step is to set proper delay times for key state transitions . Five ©2000-2008 Tibbo Technology Inc.
  • Page 505: Servicing Keypad Events

    TIDE and Tibbo BASIC User Manual different properties are responsible for that: kp.pressdelay kp.longpressdelay kp.repeatdelay kp.releasedelay , and kp.longreleasedelay . Each property sets the transition delay time in 10ms increments. Setting a property to 0 means that the corresponding transition will never happen. Note that the maximum value for each property is 254, not 255.
  • Page 506 <F4>, <E> (enter) and <C> (cancel). Notice how key codes in their hex representation reflect the number of the scan line (high digit) and return line (low digit): Set up the kp. object to work correctly with your hardware: ©2000-2008 Tibbo Technology Inc.
  • Page 507 TIDE and Tibbo BASIC User Manual kp.scanlinesmapping="24,25,26,27" kp.returnlinesmapping="28,29,30,31" io.num=PL_IO_NUM_24 io.enabled=YES io.num=PL_IO_NUM_25 io.enabled=YES io.num=PL_IO_NUM_26 io.enabled=YES io.num=PL_IO_NUM_27 io.enabled=YES 'we are not going to change default delay values -- we like them as they are (we came up with them, after all) kp.autodisablecodes=str(PL_KP_EVENT_PRESSED)+",49"...
  • Page 508: Properties, Methods, Events

    .Enabled Property Enables or disables the keypad. Function: Enum (no_yes, byte) Type: 0- NO (default): The keypad is disabled. Value Range: 1- YES: The keypad is enabled. See Also: Preparing the Keypad for Operation ©2000-2008 Tibbo Technology Inc.
  • Page 509: Longpressdelay Property

    TIDE and Tibbo BASIC User Manual Details The keypad matrix is being scanned and your application receives the on_kp on_kp_overflow events only when the keypad is enabled (kp.enabled= 1- YES). The following properties can be changed only when the keypad is disabled (kp.
  • Page 510: On_Kp Event

    This event can only be generated when the keypad is enabled (kp.enabled = 1- YES). On_kp_overflow Event Function: Indicates that the keypad buffer has overflown and some key events may have been lost. Declaration: on_kp_overflow Servicing Keypad Events See Also: Details ©2000-2008 Tibbo Technology Inc.
  • Page 511: Pressdelay Property

    TIDE and Tibbo BASIC User Manual The keypad buffer stores up to 16 keypad events. Each such event causes the on_kp generation. If your application is slow to process the keypad events, it is possible to overflow the keypad by pressing the keys in rapid succession. Once the buffer overflows, the keypad is disabled automatically (kp.enabled...
  • Page 512: Repeatdelay Property

    (see io.num io.enabled This property can only be changed when the keypad is disabled (kp.enabled = 0- NO). Setting the property to "" means that the keypad will have no return lines. A ©2000-2008 Tibbo Technology Inc.
  • Page 513: Scanlinesmapping Property

    TIDE and Tibbo BASIC User Manual keypad must have at least one return line to be able to work. Return lines of the keypad should be separate from the scan lines (see scanlinesmapping ). The keypad will not work properly if you designate any I/O line as both a scan and return line.
  • Page 514: Migrating From The Wa1000

     Detect disassociation from the network.  Detect Wi-Fi interface power-down or malfunction. The present incarnation of the wln object is intended to work with Tibbo's GA1000 802.11b/g add-on board. Previous version of the .wln object worked with the now obsolete WA1000 add-on board.
  • Page 515: Overview

    TIDE and Tibbo BASIC User Manual Setting MAC address (wln.mac ): it is now optional. The Wi-Fi add-on has a  factory-assigned MAC. Leave the wln.mac uninitialized ("0.0.0.0.0.0"), boot up ( wln.boot ) and the pre-assigned MAC will be used.
  • Page 516: Wi-Fi Parlance Primer

    Tibbo Basic application execution to wait for the wln interface to complete required operation ("task"). You program gives the wln object a task to perform, and then it is free to go and do other things.
  • Page 517 TIDE and Tibbo BASIC User Manual The wln object can only work on a single task at a time. You cannot request another task execution until the previous one is finished! The following example shows a wrong way of tasking: 'THIS WON'T WORK! wln.scan("NET1")
  • Page 518 '... continue in this fashion End Select End Sub '------------------------------------------- On_wln_event(wln_event pl_wln_events) 'here we catch hardware problems and disassociations -- also asynchronously End Sub Notice the on_wln_event in the code above. It allows us to catch "problems". ©2000-2008 Tibbo Technology Inc.
  • Page 519: Wln State Transitions

    Wi-Fi hardware, after which the boot process can be repeated. The on_wln_event is generated when the GA1000 goes offline, either as a result of a deliberate reset, or in case the Wi-Fi hardware malfunctions. Transition between the idle and associated states happens as a result of successful association.
  • Page 520: Brining Up Wi-Fi Interface

    Applying reset  Configuring Interface Lines  Setting MAC address (optional)  Selecting domain  Booting up the hardware  Setting IP, Gateway, and Netmask (optional)  Setting TX power (optional)  And now the code itself: ©2000-2008 Tibbo Technology Inc.
  • Page 521: Allocating Buffer Memory

    '----- set MAC address (optional) ----- wln.mac="0.100.110.120.130.140" '----- set domain ----- wln.domain=PL_WLN_DOMAIN_FCC '----- boot up the GA1000 ----- romfile.open("ga1000fw.bin") wln.boot(romfile.offset) '----- setup the IP, gateway, netmask ----- wln.ip="192.168.1.86" wln.gatewayip="192.168.1.1" wln.netmask="255.255.255.0" '----- set TX power (optional) ----- wln.settxpower(15)
  • Page 522: Applying Reset

    Applying Reset The Wi-Fi module requires a hardware reset for correct operation and there is a dedicated reset (RST) inteface pin for that. Any I/O line of your Tibbo module can be used to control the reset line. To reset the Wi-Fi module, enable the GPIO line that controls the reset (let's assume it is GPIO #51) and set it to LOW first, HIGH next.
  • Page 523: Configuring Interface Lines

    TIDE and Tibbo BASIC User Manual Configuring Interface Lines The Wi-Fi module interacts with your BASIC-programmable module through an SPI interface. The SPI interface has four signals: chip select (CS), clock (CLK), data in (DI), and data out (DO). Any four I/O lines of your programmable module can be selected to control the SPI interface.
  • Page 524: Selecting Domain

    Wi-Fi module, and this is what wln.boot really does. The firmware file is called "ga1000fw.bin" (the file can be downloaded from Tibbo website). The file must be added to your Tibbo Basic project as a binary resource file .
  • Page 525: Setting Ip, Gateway, And Netmask (Optional)

    ). We noticed that many people find it "unusual" that Tibbo hardware device would turn out to have two IP addresses. In fact, this is completely normal. On the PC, every network interface has an IP of its own as well.
  • Page 526: Setting Wep Mode And Key

    Platforms After the execution of the above, s string may contain something like this: "TIBBO, c1100_1,WNET2". When called with the argument set to the name of a particular network, the wln. scan method will return additional data on this network: Wln.scanresultssid...
  • Page 527: Associating With Selected Network

    TIDE and Tibbo BASIC User Manual Wi-Fi devices routinely define four WEP keys, but Tibbo hardware only uses a single key (key 1). Associating With Selected Network Association is a process by which your Wi-Fi device establishes a network link with an access point or another wireless station running an ad-hoc network.
  • Page 528: Creating Own Ad-Hoc Network

    We are talking about the network your hardware has created -- you can't terminate an ad-hoc network of someone else. Note that wln.networkstop is a wln task and there is a certain correct way of handling tasks. ©2000-2008 Tibbo Technology Inc.
  • Page 529: Rebooting

    TIDE and Tibbo BASIC User Manual Rebooting Rebooting is done by applying a hardware reset to the Wi-Fi module. When the Wi-Fi interface add-on goes offline, the wln object will detect this in a matter of milliseconds. Your application can stay and wait for this:...
  • Page 530: Associationstate R/O Property

    2- PL_WLN_OWN_NETWORK: The Wi-Fi interface is running its own ad-hoc network. See Also: Associating With Selected Network Disassociating From the Network Creating Own Ad-hoc Network Terminating Own Ad-hoc Network Detecting Disassociation or Power-down Details ©2000-2008 Tibbo Technology Inc.
  • Page 531: Boot Method

    TIDE and Tibbo BASIC User Manual After the successful association, which is initiated through the wln.associate method, the value of this property changes to 1- PL_WLN_ASSOCIATED. The value is reset back to 0- PL_WLN_NOT_ASSOCIATED if disassociation occurs. Every time this happens, an...
  • Page 532: Buffrq Method

    The Wi-Fi interface will only be able to successfully send out packets that fit in the TX buffer; larger packets will be truncated. There is no need to allocate any buffer for packet reception. ©2000-2008 Tibbo Technology Inc.
  • Page 533: Clkmap Property

    TIDE and Tibbo BASIC User Manual .Clkmap Property Sets/returns the number of the I/O line which will control Function: the clock (CLOCK) input of the Wi-Fi module's SPI interface. Enum (pl_io_num, byte) Type: Platform-specific. See the list of pl_io_num constants in Value Range: the platform specifications.
  • Page 534: Disassociate Method

    1- PL_WLN_DOMAIN_EU: European Union. Allowed channels: 1-13. 2- PL_WLN_DOMAIN_JAPAN: Japan. Allowed channels: 1- 3- PL_WLN_DOMAIN_OTHER: All other countries. Allowed channels: 1-14. See Also: Selecting Domain Scanning for Wi-Fi Networks Associating With Selected Network Creating Own Ad-hoc Network ©2000-2008 Tibbo Technology Inc.
  • Page 535: Domap Property

    TIDE and Tibbo BASIC User Manual Details This property can't be changed while the Wi-Fi hardware is operational (wln. enabled = 1- YES). Note that domain selection only affects association (wln. associate ), not the scanning process (wln.scan ) or the ability of the Wi-Fi interface to start its own ad-hoc network (wln.networkstart...
  • Page 536: Gatewayip Property

    There are certain rules on MAC address selection -- see Setting MAC Address topic for details. This property can only be written to while the Wi-Fi hardware is not operational ( wln.enabled = 0- NO) and when no socket is engaged in communications ©2000-2008 Tibbo Technology Inc.
  • Page 537: Netmask Property

    <> 0- PL_SSTS_CLOSED and sock.currentinterface = 2- PL_INTERFACE_WLN. The GA1000 add-on board already has a proper MAC address internally. To use this MAC, leave the wln.mac at "0.0.0.0.0.0" when booting up the wln interface with the wln.boot method. After a successful boot,the wln.mac property will contain the MAC address obtained form the GA1000.
  • Page 538: Networkstop Method

    On_wln_event Event Function: Generated when the wln object detects disassociation from the wireless network or the Wi-Fi hardware is disconnected, powered-down, or is malfunctioning. Declaration: on_wln_event(wln_event as pl_wln_events) See Also: Detecting Disassociation or Offline State Part Description ©2000-2008 Tibbo Technology Inc.
  • Page 539: On_Wln_Task_Complete Event

    TIDE and Tibbo BASIC User Manual wln_ Registered event: event 0- PL_WLN_EVENT_DISABLED: Wi-Fi hardware has been disconnected, powered down, or is malfunctioning. 1- PL_WLN_EVENT_DISASSOCIATED: Wi-Fi interface has been disassociated from the wireless network. Details Multiple on_wln_event events may be waiting in the event queue.
  • Page 540: Rssi R/O Property

    = 1- PL_WLN_ASSOCIATED), is running its own network (wln.associationstate = 2- PL_WLN_OWN_NETWORK), or if the Wi-Fi hardware is not online (wln.enabled 0- NO). The method will return 0- ACCEPTED if the task is accepted for processing. ©2000-2008 Tibbo Technology Inc.
  • Page 541: Scanresultbssid R/O Property

    TIDE and Tibbo BASIC User Manual The task is completed when the wln.task R/O property becomes 0- PL_WLN_TASK_IDLE. The on_wln_task_complete event will also be generated at that time. After the completion, the following read-only properties will be updated: If the ssid argument was left empty, the wln.scanresultssid...
  • Page 542: Scanresultchannel R/O Property

    String Type: 1-32 characters Value Range: See Also: Scanning for Wi-Fi Networks wln.scanresultbssid wln.scanresultbssmode wln.scanresultchannel wln. scanresultrssi ©2000-2008 Tibbo Technology Inc.
  • Page 543: Settxpower Method

    TIDE and Tibbo BASIC User Manual Details If the wln.scan method was invoked with its name argument left empty, the wln.scanresultssid will contain the list of all discovered networks. If the name argument specified a particular network and scanning found this network to be present, then this property will contain the name of this network.
  • Page 544: Ssid Property

    Notice that only one WEP key (wepkey1) is used by the wln object. .Ssid Property Obsolete. This parameter is now supplied directly, as the argument for the wln.associate method. .Task R/O Property Indicates current wln task being executed. Function: Enum (pl_wln_tasks, byte) Type: ©2000-2008 Tibbo Technology Inc.
  • Page 545: Wepkey1 Property

    TIDE and Tibbo BASIC User Manual 0- PL_WLN_TASK_IDLE (default): No task is in progress. Value Range: 1- PL_WLN_TASK_SCAN: Scan task is in progress (initiated by wln.scan 2- PL_WLN_TASK_ASSOCIATE: Association task is in progress (initiated by wln.associate 3- PL_WLN_TASK_SETTXPOWER: TX power adjustment is in progress (initiated by wln.settxpower...
  • Page 546: Wepmode Property

    - Updated all other information in relation to the above.  Changes in the object manual: - Updated fd.find method; - Documented new fd.rename method. - In connection with the above, renamed "Creating and Deleting Files" into ©2000-2008 Tibbo Technology Inc.
  • Page 547 TIDE and Tibbo BASIC User Manual Creating, Deleting, and Renaming Files , expanded topic content.  Changes in the sock object manual: - Updated sock.close sock.reset , and sock.discard topics -- these methods are ignored when called from within an HTML page;...
  • Page 548  Corrected a mistake in the Main Parameters topic (net object). The topic incorrectly stated that the Tibbo Basic application can't change the MAC address, which is, in fact, possible.  Correction: default value for the net.ip property is "1.0.0.1", not "127.0.0.1".
  • Page 549 TIDE and Tibbo BASIC User Manual  Expanded Establishing Outgoing Connections Closing Connections topics. Both topics now contain "Do not forget! Connection Handling is fully asynchronous" sections.  Added "Socket re-use after connection closing" section to the Closing Connections topic.
  • Page 550  Updated certain screenshots in several topics.  Added Image Editor topics: Built-in Image Editor Image Menu Image Editor Toolbar Tool Properties Toolbars (+ all subtopics).  Updated Adding, Removing, and Saving Files topic (added image editor- related info). ©2000-2008 Tibbo Technology Inc.
  • Page 551 TIDE and Tibbo BASIC User Manual ---------------- 06JULY2006 release  Added new platform -- EM1000  Added "Platform revision Programming Information" topics to EM202 EM1000 platform documentation. Stor object got new property- stor.base . Entire description of the object ...
  • Page 552 Update History (for this Manual) Mincount Function Minutes Function Month Function Year Function ---------------- 11JAN2006 release  Improved indexes -- better context search.  Added L1008 L1009 ---------------- 02JAN2006 release  Initial release of manual. ©2000-2008 Tibbo Technology Inc.
  • Page 553 TIDE and Tibbo BASIC User Manual baudrate property Index Beep beep.divider beep.play - - - Beeper blocking code - Operator blue line - & - boolean Break breakpoint &b Broadcast &h buffer memory - * - buffer overruns 244, 307...
  • Page 554 - F - ddstr ddval Debug Mode 27, 114 14, 26 Debug version Decision Structures Declares fd.availableflashspace Declaring Procedures fd.buffernum Declaring Variables fd.capacity default gateway fd.checksum fd.close direction control via RTS fd.copyfirmware ©2000-2008 Tibbo Technology Inc.
  • Page 555 TIDE and Tibbo BASIC User Manual fd.create goto fd.cutfromtop graceful disconnect fd.delete green LED fd.filenum green status fd.fileopened fd.filesize - H - fd.find fd.flush half duplex fd.format halt fd.getattributes Handling RX buffer overruns fd.getbuffer Header files fd.getdata fd.getfreespace hours fd.getnextdirmember hover your mouse fd.getnumfiles...
  • Page 556 Local Scope L1008 loop L1009 Loop structures label 88, 132 loopback lbin lstr lcd.backcolor lstri lcd.bitsperpixel lval lcd.bluebits - M - lcd.bmp lcd.enabled lcd.error main window lcd.fill Master Process lcd.filledrectangle lcd.fontheight memory allocation 213, 239, 297 ©2000-2008 Tibbo Technology Inc.
  • Page 557 TIDE and Tibbo BASIC User Manual memory capacity on_sock_event menu on_sock_inband messages embedded within the TCP data stream on_sock_overrun on_sock_tcp_packet_arrival on_sys_init 212, 220 mincount on_sys_timer minimalistic on_wln_event minutes on_wln_task_complete MOD Operator OR Operator month - P - more than one serial port...
  • Page 558 Sending data 243, 298, 299, 304 sock.connectiontout ser.autoclose sock.currentinterface ser.baudrate sock.discard ser.bits sock.endchar ser.ctsmap sock.escchar ser.dircontrol sock.event ser.div9600 sock.eventsimple ser.enabled sock.getdata ser.escchar sock.getinband ser.esctype sock.httpmode ser.flowcontrol sock.httpnoclose ser.getdata sock.httpportlist ser.interchardelay sock.httprqstring ser.interface sock.inbandcommands ser.mode sock.inconenabledmaster ©2000-2008 Tibbo Technology Inc.
  • Page 559 - T - sock.targetip sock.targetport Target sock.tx2buffrq sock.tx2len sock.txbuffrq sock.txbuffsize Templates sock.txclear terms sock.txfree Tibbo Basic code within an HTML file sock.txlen Timekeeping sock.varbuffrq timeouts socket automatic switching timer 37, 214 stack pointer toolbars state tooltip Statements...
  • Page 560 - W - year watch yellow line watching arrays yellow status weekday wend while 82, 95 who can connect window wln.associate wln.associationstate wln.boot wln.bssmode wln.buffrq wln.buffsize wln.csmap wln.defaultibsschannel wln.disassociate wln.domain wln.enabled wln.gatewayip wln.ip wln.mac wln.netmask wln.rssi wln.scan ©2000-2008 Tibbo Technology Inc.

Table of Contents