background image

411

TIDE and Tibbo BASIC User Manual

©2000-2008 Tibbo Technology Inc.

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" 

'RST,D/C,R/W,E,CS,D7-0

   

'configure control lines as outputs

io.num=PL_IO_NUM_44 

'RST

io.enabled=YES
io.num=PL_IO_NUM_43 

'D/C

io.enabled=YES
io.num=PL_IO_NUM_42 

'R/W

io.enabled=YES
io.num=PL_IO_NUM_41 

'E

io.enabled=YES
io.num=PL_IO_NUM_40 

'CS

io.enabled=YES

'set resolution

lcd.width=128
lcd.height=96

'optionally set lcd.rotated here

lcd.enabled=YES 

'done!

Himax HX8309 (Ampire AM176220)

Controller: Himax HX8309.

Panel: Ampire AM176220 and similar panels.

Type: TFT, color, 16 bits/pixel.

Locking: Supported, display picture stays stable for at least 1 second after the
display is 

locked

. Unfortunately, there appears to be a hardware bug in the

HX8309. This bug causes one of the horizontal lines of the panel (usually, the top
or bottom line) to display random garbage while the display is locked. We have
some ideas for workaround -- contact us if you encounter this problem. 

Test hardware: TEV-LB2 test board. This board is a part of the EM1000-TEV
development system. See Programmable Hardware Manual for details.

I/O mapping for AM176220

The panel requires 5 I/O lines and a 17-bit data bus, of which only bits DB7-0 are
used (8-bit interface mode). Control lines are RESETRSWRRD, and CS. Each
control line can be connected to any I/O pin of your device, and each such I/O pin
must be configured as an output (if your device requires explicit I/O line buffer
configuration). The data bus can be connected to any 8-bit port. DO NOT configure
this port for output.

The controller also has IM0 and IM3 interface type selection pin. For proper
operation, tie IM0 to Vcc, IM3 - to the ground.

The value of the 

lcd.iomapping

 property must be set correctly for the display to

work (see 

Preparing the Display for Operation

). For this particular display, the

mapping string consists of 6 comma-separated decimal values:

1. Number of the I/O line connected to RESET.

411

422

395

Содержание GA1000

Страница 1: ... USER S MANUAL FCC ID XOJGA1000 ...

Страница 2: ...correct the interference by one of more of the following measures Reorient or relocate the receiving antenna Increase the separation between the equipment and receiver Connect the equipment into an outlet on a circuit different from that to which the receiver is connected Consult the dealer or an experienced Radio TV technician for help Use only shielded cables to connect I O devices to this equip...

Страница 3: ...plates 18 Adding Removing and Saving Files 20 Resource Files 20 Built in Image Editor 22 Coding Your Project 22 Project Browser 23 Code Auto completion 24 Code Hinting 24 Tooltips 26 Supported HTML Tags 26 Making Uploading and Running an Executable Binary 27 Two Modes of Target Execution 28 Debugging Your Project 28 Target States 29 Exceptions 30 Program Pointer 30 Breakpoints 31 The Call Stack an...

Страница 4: ... Scope of Preprocessor Directives 74 Working with HTML 76 Embedding Code Within an HTML File 77 Understanding Platforms 78 Objects Events and Platform Functions Language Reference 78 79 Statements 79 Const Statement 79 Declare Statement 81 Dim Statement 82 Doevents Statement 82 Do Loop Statement 84 Enum Statement 85 Exit Statement 86 For Next Statement 87 Function Statement 88 Goto Statement 89 If...

Страница 5: ...C1013 106 C1014 106 C1015 107 C1016 107 C1017 107 C1018 108 C1019 108 C1020 108 C1021 109 C1022 109 C1023 110 C1024 110 L1001 110 L1002 111 L1003 111 L1004 111 L1005 111 L1006 112 L1007 112 L1008 112 L1009 113 Objects Properties Methods Events Development Environment 113 113 Installation Requirements 113 User Interface 114 Main Window 114 Operation Modes 115 Menu Bar 115 File Menu 116 Edit Menu 11...

Страница 6: ...ject Settings 127 New Project 128 Add File to Project 128 Graphic File Properties Dialog 128 Panes 128 Call Stack 129 Output 129 Project 129 Browser 130 Files 130 Watch 130 Colors 131 Language Element Icons Glossary of Terms 131 131 Compilation Unit 131 Compiler 132 Construct 132 Cross Debugging 132 Identifier 132 Keyword 132 Label 132 Linker 132 P Code 132 Syscall 133 Target 133 Virtual Machine P...

Страница 7: ...tform dependent Constants 159 Enum pl_redir 160 Enum pl_io_num 162 Enum pl_int_num 162 Enum pl_sock_interfaces 163 Platform dependent Programming Information 166 DS1202 Platform 167 Memory Space 167 Supported Objects 167 Platform dependent Constants 167 Enum pl_redir 169 Enum pl_io_num 170 Enum pl_int_num 170 Enum pl_sock_interfaces 171 Platform dependent Programming Information 174 DS1206 Platfor...

Страница 8: ...nction 208 Stri Function 209 Strsum Function 209 Strtof Function 210 Val Function 210 Vali Function 211 Weekday Function 211 Year Function 212 Object Reference 212 Sys Object 212 Overview 212 On_sys_init Event 213 Buffer Management 214 System Timer 215 PLL Management 216 Serial Number 217 Miscellaneous 217 Properties Methods Events 217 Buffalloc Method 218 Currentpll R O Property Selected Platform...

Страница 9: ...operty 249 Bits Property 249 Ctsmap property Selected Platforms Only 250 Dircontrol Property 250 Div9600 R O Property 251 Enabled Property 251 Escchar Property 251 Esctype Property 253 Flowcontrol Property 253 Getdata Method 254 Interchardelay Property 255 Interface Property 255 Mode Property 256 Newtxlen R O Property 257 Notifysent Method 257 Num Property 258 Numofports R O Property 258 On_ser_da...

Страница 10: ... Port Switchover 286 Incoming Connections on Multiple Sockets 287 Establishing Outgoing Connections 288 Sending UDP broadcasts 290 Closing Connections 292 Checking Connection Status 294 More On the Socket s Asynchronous Nature 297 Sending and Receiving data 297 Allocating Memory for Buffers 298 Using Buffers in TCP Mode 299 Using Buffers in UDP Mode 300 TX and RX Buffer Memory Status 301 Receiving...

Страница 11: ...y 335 Httpnoclose Property 335 Httpportlist Property 336 Httprqstring R O Property 337 Inbandcommands Property 337 Inconenabledmaster Property 338 Inconmode Property 338 Localport R O Property 339 Localportlist Property 339 Newtxlen R O Property 339 Nextpacket Method 340 Notifysent Method 340 Num Property 341 Numofsock R O Property 341 Outport Property 342 On_sock_data_arrival Event 342 On_sock_da...

Страница 12: ...e Port Manipulation Without Pre selection 368 Controlling Output Buffers 369 Working With Interrupts 370 Properties Events Methods 370 Enabled Property Selected Platforms Only 370 Intenabled Property 371 Intnum Property 371 Invert Method 371 Lineget Method 372 Lineset Method 372 Num Property 373 On_io_int Event 373 Portenabled Property Selected Platforms Only 373 Portget Method 374 Portnum Propert...

Страница 13: ...309 Ampire AM176220 412 Properties and Methods 414 Backcolor Property 414 Bitsperpixel R O Property 415 Bluebits R O Property 415 Bmp Method 416 Enabled Property 417 Error R O Property 417 Fill Method 418 Filledrectangle Method 418 Fontheight R O Property 419 Fontpixelpacking R O Property 419 Forecolor Property 420 Getprintwidth Method 420 Greenbits R O Property 421 Height Property 421 Horline Met...

Страница 14: ... File based and Direct Sector Access Coexistence 453 Prolonging Flash Memory Life 454 Ensuring Disk Data Integrity 456 Properties and Methods 457 Availableflashspace R O Property 458 Buffernum Property 458 Capacity R O Property 459 Checksum Method 460 Close Method 460 Copyfirmware Method 461 Cutfromtop Method 462 Create Method 463 Delete Method 463 Filenum Property 464 Fileopened R O Property 464 ...

Страница 15: ...Wln Object 498 Migrating From the WA1000 499 Overview 500 Wi Fi Parlance Primer 500 Wln Tasks 503 Wln State Transitions 504 Brining Up Wi Fi Interface 505 Allocating Buffer Memory 506 Applying Reset 507 Configuring Interface Lines 507 Setting MAC Address Optional 508 Selecting Domain 508 Booting Up the Hardware 509 Setting IP Gateway and Netmask Optional 509 Setting TX Power Optional 509 Scanning ...

Страница 16: ...22 On_wln_event Event 523 On_wln_task_complete Event 524 Rssi R O Property 524 Scan Method 525 Scanresultbssid R O Property 525 Scanresultbssmode R O Property 526 Scanresultchannel R O Property 526 Scanresultrssi R O Property 526 Scanresultssid R O Property 527 Settxpower Method 527 Setwep Method 528 Ssid Property 528 Task R O Property 529 Wepkey1 Property 529 Wepkey2 Property 529 Wepkey3 Property...

Страница 17: ...y are written using a language similar to BASIC and are stored on a Tibbo module separately from the core OS of the module TiOS This allows for simple modification of your device functionality even by the end user if you so allow Tibbo Basic itself is exactly the same for all TiOS enabled devices Hardware differences are expressed through so called platforms Change the platform and you re programm...

Страница 18: ...where the resulting END PRODUCT is manufactured exported advertised or sold TIBBO is not capable of monitoring any activities by its customers partners or distributors aimed at creating any END PRODUCT does not provide advice on potential legal issues arising from creating such END PRODUCT nor explicitly recommends the use of any of its PROGRAMMABLE DEVICES in combination with any BASIC APPLICATIO...

Страница 19: ... any other third party 8 TIBBO reserves the right to halt the production or availability of any of its PRODUCTS at any time and without prior notice The availability of a particular PRODUCT in the past is not an indication of the future availability of this PRODUCT The sale of the PRODUCT to you is solely at TIBBO s discretion and any such sale can be declined without explanation 9 TIBBO makes no ...

Страница 20: ...o offer customizable or programmable solutions but to implement those solutions you would really have to be an engineer and know C C quite well So there was clearly a need for an easy to use programming system which would democratize this market as well Principle One Easy To Write Easy to Debug Choosing BASIC as our inspiration was the natural thing to do for us It s a language which doesn t requi...

Страница 21: ... and control program flow and hardware dependant input output For example many languages contain a print statement which prints something to the screen Since all PCs in the world are similar this works However this makes little sense for embedded platform which have vastly different input output resources Depending on the device it may or may not have a screen a serial port networking etc etc In o...

Страница 22: ...ess errors even when doing seemingly strange things such as putting large values into variables that cannot hold them The language will deal with it silently in a very predictable and logical way but will not pop up an error Principle Six Event Driven Programming Users of VB and Delphi and other Windows based tools will find this principle familiar However if most of your experience with BASIC was...

Страница 23: ...and control it This is called cross debugging As covered under Our Language Philosophy Tibbo Basic is capable of running on various hardware devices Each type of hardware device on which Tibbo Basic runs is called a platform And now the anatomy of the target The target runs an operating system called TiOS Tibbo Operating System TiOS runs two processes One is the Master Process This is the process ...

Страница 24: ...ach platform is fixed You cannot add new objects or create multiple instances of the same object Objects have properties methods and events A property can be likened to an attribute of the object and a method is an action that the object can perform Events are described in the next section Objects are covered in further detail under Objects Events and Platform Functions Events An event is somethin...

Страница 25: ...DS using a network cable WAS 1499 or similar to the same hub your computer is connected to or directly to the computer with a cross network cable WAS 1498 or similar Make sure your local firewall such as the XP SP2 firewall is disabled or does not block broadcast UDP messages This is essential for communications between TIDE and the DS202 while debugging Run Device Explorer Start Programs Tibbo Ti...

Страница 26: ...le pressing the SETUP button Upload will then commence Starting a New Project To begin a new project select File New You will be presented with the following dialog Platform Select EM202 you can use EM1000 as well Available project types Select Empty 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 Broadcas...

Страница 27: ...irewall or configure it to open a specific port Once you have located your target click Select You will be returned to the previous dialog and the MAC address for your target will appear under Target Address You have now specified all of the required settings for a new project Click OK and proceed Writing Code Once you have started your new project you will be presented with a blank file main tbs ...

Страница 28: ...e pattern object pat used to play the pattern only supports patterns of up to 16 steps So we have to play our pattern in parts one after the other and track our progress through the pattern this is what the counters are for So far we have prepared the ground Let us move to the first piece of executable code sub on_sys_init event handler for the init event Fires whenever the device powers on hello_...

Страница 29: ...ust doesn t know how to do it yet This comes next sub play_next plays the next chunk of our large pattern if length play_position then exit sub if we have reached the end of the pattern stop dim chunk_len as integer internal integer for the length of current chunk to be played chunk_len length play_position 1 calculate how much of the large string is left if chunk_len PAT_PLAY_CHUNK_LENGTH then ch...

Страница 30: ...lay_position 1 play_next end sub sub on_pat play_next end sub sub play_next if length play_position then exit sub dim chunk_len as integer chunk_len length play_position 1 if chunk_len PAT_PLAY_CHUNK_LENGTH then chunk_len PAT_PLAY_CHUNK_LENGTH dim chunk as string chunk mid hello_world play_position chunk_len pat play chunk YES play_position play_position chunk_len end sub Building Uploading and Ru...

Страница 31: ...umber of DSes Programming with TIDE 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 The section called Managing Projects provides an overview of the general structure of a T...

Страница 32: ...ce files Multiple files without any set extension Contain resources such as images needed for other files Some resource files cfg txt ini can be edited from within TIDE cfg txt and ini files are considered to be text files and can be edited using TIDE s built in text editor bmp jpg and png files are graphical files these will be opened using TIDE s built in image editor Note that the only really s...

Страница 33: ...ain the project sub folder The actual files for your project will go into the project sub folder Target address Platform specific See platform documentation The address of the target you will use for debugging and testing this project This should be a reachable address with a live target Your project will still be created even if you do not specify this parameter but you will not be able to upload...

Страница 34: ...s platform along with their paths relative to the platform file For example template1 name Simple Project description Simple project template icon em202 simple ico path em202 simple simple tpr The definition above would specify a template project called Simple Project whose path would be em202 simple simple tpr Remember the folder and files for this project would not be automatically created Addin...

Страница 35: ... bmp jpg png gif ico pcx extension will prompt a request for additional information file size in pixels and if appropriate for the file type the color mode selection RGB or palette This last selection won t be available if selected file type only supports true color or paletted mode Format listbox will be disabled if the type of the image file you are adding is already known Specifically If your i...

Страница 36: ...de per se these may be image files sound files or any other fixed binary data which is not to be interpreted or modified by the 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 within the final compiled binary file and may be accessed from within the program or by the built in HTTP server Resource files are...

Страница 37: ...008 Tibbo Technology Inc 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 119 122 ...

Страница 38: ...eir methods properties and events as well as all procedures and global variables of your project The tree is updated in real time using a dynamic background parser which constantly analyzes your source code The tree features icons for the various constructs An icon next to an event is grayed inactive if this event does not have an event handler implemented in the project The icon becomes active wh...

Страница 39: ...n a global variable which is not yet defined using the dim s tatement will make the cursor jump to the location where this variable is declared using the declare statement Double clicking on a defined global variable will make the cursor jump to the location where this variable is defined Hovering the cursor over an item in the displays a tooltip for this item Additionally when in debug mode hover...

Страница 40: ...feature which helps you see what are the arguments for a function while writing the code for it It appears as soon as you type the opening parentheses for a procedure It looks like this You can see the number of arguments required and their types as well as the return type if any The highlighted part shows what syntax element you should type in next You may invoke code hinting manually by pressing...

Страница 41: ...readability Supported HTML Tags section details which tags you can use to beautify your tooptips Your comment must be on the same line as the function definition or immediately following it The comment can contain multiple lines if every line begins with a comment character These lines must be consecutive with no blank lines in between For example function blink num as integer as boolean USER DEFI...

Страница 42: ...old b text then you will get this output Boldtext Writing b Bold b text or b Bold b text will produce correct result Bold text Making Uploading and Running an Executable Binary An Executable Binary File is a file tpc type which contains your project in compiled form along with any resource files It is uploaded to the target where it is actually executed by the TiOS Virtual Machine Making a Binary ...

Страница 43: ...lso reboots the target before running it This ensures that target starts running the newly uploaded program from a fresh state You may also reboot your device manually at any time by selecting Debug Restart or clicking the Restart button on the Debug toolbar These actions are incremental This means that when uploading a build is performed if needed When running a build and an upload are performed ...

Страница 44: ...ything of this sort It is truly uploaded and run on your target just like it would run in real life As covered above the first thing you would have to do to begin debugging a debug binary would be to run it using F5 Once you press F5 or Debug Run your project will be built if necessary uploaded if necessary and started Once execution has started there are several ways in which you may control and ...

Страница 45: ...nces one step whenever TIDE gets a reply to a debug command Communication problem The circle is yellow and does not move This state means TIDE did not receive any reply to debug commands for more than 6 seconds The program may be still running on the target No Communication The circle is red and does not move Occurs when TIDE did not receive any reply to debug commands for more than 12 seconds The...

Страница 46: ... waiting for you to tell it what to do You can now control it by stepping This line is displayed whenever the Virtual Machine has been paused while executing code This can be achieved by setting a breakpoint or simply selecting Debug Pause at the right time The program pointer will only stop on lines which contain actual executable code dim x as byte the program pointer won t stop here as this isn...

Страница 47: ...ts Breakpoints may be toggled set cleared by putting the cursor in the line in which you wish to place or remove the breakpoint and pressing F9 or selecting Debug Toggle Breakpoint Alternatively you may also toggle a breakpoint by clicking on the margin of the code at the point in which you wish to have a breakpoint You may remove all breakpoints from an entire project including any files which ar...

Страница 48: ...in the call stack which is not the currently executing procedure would display the stack pointer This pointer would be displayed in the source code within the procedure you double clicked and would highlight the line from which execution would resume once control returns to this procedure The watch pane would also interpret variables as relative to the procedure you ve just highlighted The stack p...

Страница 49: ...ut of the current function i e when your other function calls it such as in the case of an event handler Run to Cursor The cursor in this case is the text insertion point The little blinking black line You can place the cursor anywhere within the body of your program and have the program execute until it reaches that point When and if that point is reached the program pointer would display Jump to...

Страница 50: ...e the watch pane has focus this will bring up an Add to Watch List dialog Type the name of a variable or property to watch and press OK Alternatively double click on the empty space in the watch pane to obtain the same result You can also select Debug Add to Watch List from the Menu Additionally there is an Add to Watch List button on the Debug toolbar You can right click on the variable or proper...

Страница 51: ...property Double click on the value field you will be prompted for a new value For numerical variables you may use hex or binary notation h b For strings you will be presented with the HEX editor allowing you to modify the string or the HEX codes of its characters Once a new value is entered it will be actually written to memory on the target and will be read again before being displayed in the wat...

Страница 52: ...ist button on the Debug toolbar The Watch Tooltip This is the watch tooltip When you hover the mouse cursor over an identifier in the source while in debug mode you will see a tooltip with the current value for this identifier For now this won t work for arrays If you want to inspect the values of an array add this array to the watch list The Project Browser The Project Browser is a tab in the Pro...

Страница 53: ...n pointer highlights the end sub keyword for sub_one the value of x in the watch would be 1 When the pointer highlights the end sub for sub_two the value of x in the watch would be 2 Note that these are two different local variables Similarly when the execution pointer is at the end sub of sub_three the x variable in the watch will be undefined it will display a question mark These same rules appl...

Страница 54: ...omatically run on upload or reboot release versions are run on upload or reboot and cannot be debugged using the various debug facilities By default this is checked Once you ve debugged your project and wish to deploy it uncheck this and build your final version Output binary file name The name for the bin file of the compiled project Transport Ethernet is not the only potential means of communica...

Страница 55: ...t on this subject and we did not set out to compete with any of them This is a mere attempt at explaining Tibbo Basic no more no less Good luck Program Structure A typical Tibbo Basic source code file a compilation unit with the tbs extension contains the following sections of code Include Statement s These are used to include other files from the same project such as header files tbh containing g...

Страница 56: ...re are several important things you should know about writing in Tibbo Basic You Can Put Comments in Your Code The apostrophe character marks the beginning of a comment Anything following this character until the end of a line is considered to be a comment and will not be processed by the compiler x 1 1 I am a comment x y 0 this line would not cause an error because it won t even execute It is com...

Страница 57: ...a string literal is a constant string value like hello world s I am a string literal s1 s How to Use Single Quote Marks These are different than the apostrophes which begin a comment An apostrophe looks like this while a single quote mark looks like this and is usually located on the tilde key Single quote marks are used to define a numerical constant which contains the value for an ASCII code For...

Страница 58: ...orrectly 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 No Tibbo Basic statements require the use of colons Naming Conventions Identifiers An identifier is t...

Страница 59: ... execution of an application Each variable has a name the identifier used to refer to the value the variable contains and a type which specifies how much data this variable can contain and also what kind of data it may contain Not every variable type is supported on every platform You will find related information in the Supported Variable Types topic in the platform documentation If you attempt t...

Страница 60: ...s from 128 to 127 short Hardware level Signed Takes 2 bytes in memory Can hold integer numerical values from 32768 to 32767 integer Compiler level Synonym for short substituted for short at compilation Exists for compatibility with other BASIC implementations long new in V2 0 not available on all platforms Hardware level Signed Takes 4 bytes in memory Can hold integer numerical values from 2147483...

Страница 61: ...tional user defined data types More about these under User Defined Types Hardware level types are actually implemented on the machine which is used to run the final program produced by the compiler Compiler level types are substituted by other variable types on compile time The actual machine uses other variable types to represent them they are implemented for convenience while programming 4 2 4 2...

Страница 62: ... OK lval OK str tof fstr is a functional equivalent of ftostr but without mode and rnd parameters Conversions without loss Conversions marked as OK incur no loss the value being passed from variable of one type to variable of another type remains unchanged For example conversion from word into dword is done without any loss because 32 bit word variable can hold any value that the 16 bit word varia...

Страница 63: ...ide may be lost during the conversion For example converting from word type into byte type will only leave 8 bits of the original 16 bit value dim x as byte dim w as word w 12345 hex representation of 12345 is 3039 x w now x contains 57 Why Because only 39 of 3039 could fit in and decimal of h39 is 57 Notice that some conversions will cause reinterpretation and truncation at the same time Conversi...

Страница 64: ...to 16 bits Also all intermediary calculations are done using 16 bit arithmetic Consider the following example first dim x y z as byte x 150 y 200 z x y 10 result of 35 is within byte variable s range but intermidiary calculations require 16 bit ariphmetic The above example will give correct result Even though all three variables are of byte type internal calculations are 16 bit so when x y produce...

Страница 65: ... byte y 5 x 5 10 y compiler will precalculate 5 10 and then the Virtual Machine will only have to do 15 y Pre calculation reduces program size and speeds up execution When processing a string like x 50000 compiler first determines the variable of what type would be necessary to hold the fixed value and chooses the smallest sufficient variable type For example for 50000 it is obviously word Next co...

Страница 66: ...e which contains several elements of the same type 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 0 1 2 3 4 Value 15 32 4 100 30 The code to produce such an array in Tibbo Basic would look like this dim x 5 as char x 0 15 x 1 32 x 2 4 x 3 100 x 4 30 The first index in an array is 0 Thus the array above contains 5 value...

Страница 67: ...ins the sum for the first three elements 51 The TIDE and Tibbo Basic V2 0 introduced correct handling of array indices It is no longer possible for your program to point to an array element that does not exist For example if your array only has 5 elements and you try to access element number 5 the Virtual Machine will Generate an OOR Out Of Range exception and halt if your program is in the debug ...

Страница 68: ...55 2 32 48 97 5 22 3 13 18 9 87 54 4 32 35 79 124 3 5 7 9 48 8 99 This is called two dimensional array Each element in the array is now identified by an index consisting of two numbers two coordinates For example the element 2 0 contains the value 32 To create such an array you would use the following code dim x 5 6 as char x 0 0 15 x 0 1 32 x 0 2 4 x 5 2 48 x 5 3 8 x 5 4 99 Iterating through such...

Страница 69: ...e In Tibbo Basic the same can be expressed in a different way dim x as byte 10 you can think of it as 10 times of byte type Both ways of defining arrays are completely identical and you can even mix them together as we can see on the following examples of 2 dimensional arrays dim i 20 10 as byte two dimensional array 20x10 elements dim i2 20 as byte 10 same that is 20 groups of byte x 10 exactly s...

Страница 70: ...ne or several member variables Structures are declared using type end type statements as shown in the example below this is a structure with three members type my_struct x as byte y as Long s as string end type In the above example we declared a structure my_struct that has three member variables x y and s This is just a declaration you still have to define a variable with the new type you have cr...

Страница 71: ...ping data that for instance defines how many members are there what type they have etc 4 2 4 7 Enumeration Types At times it may be useful for a programmer to define his own enumeration data types for example when working with the days of the week it may be useful to refer to them by name in code rather than by number dim i as integer i 2 i is an integer and can only be assigned a numerical value ...

Страница 72: ...itly associated with the same value Now on compile time they would both be considered to be just the same Type Mapping for Enum Types When the project is being compiled all enumeration types are substituted with plain numerical values the platform on which the code is running doesn t have to know anything about Saturday or about the best day of the week for the platform the number 7 is informative...

Страница 73: ... associated with this value This usually proves to be very useful during debugging After all seeing dayofweek 2 Monday is much less cryptic than just dayofweek 2 4 2 4 8 Understanding the Scope of Variables A scope is a section of code from which you can see a variable i e assign it a value or read its value For example sub foobar x as byte dim i y as byte y x 30 for i 1 to y dim r as short r x 5 ...

Страница 74: ...ope are accessible from within any sub or function in this compilation unit dim s as string sub foo s foo assigning a value to the global string variable s end sub sub bar dim i as short i 0 s initialize s in case it contains anything already such as foo for i 1 to 5 s s bar note next i end sub at this point s contains barbarbarbarbar Local Scope This is the scope which is between the beginning an...

Страница 75: ...s 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 Statements within an HTML file are considered to be within one scope similarly to a function or sub scope with the exceptions that include and declare statements are allowed DOCTYPE HTML PUBLIC W3C D...

Страница 76: ...needs to be accessed For example let us say this is the file foo tbs public dim i as integer the integer i is defined in this file and made into a public variable It can now be used from other compilation units And this is the file bar tbs i i 5 this would cause a compiler error What is i the correct way declare i as integer lets the compiler know that i is defined elsewhere i i 5 Also if for some...

Страница 77: ...nt process you will just have to change the definition of the constant which is a single line of code When defining a list of related constants it is often convenient to use the Enum Statement and create one data type which contains this list of constants See also User Defined Types above When defining a constant within a scope this constant is visible only from within this scope It is a good idea...

Страница 78: ...types of procedures Function Procedures A function is defined using the Function Statement Functions can optionally have one or several arguments Functions always return a single value They can however change the value of the arguments passed to them using ByRef and thus indirectly return more than one value This would be an example of a function function multiply a as integer b as integer as inte...

Страница 79: ...ub statements and then used in code however at times functions can reside in a different compilation unit In such a case you must use the public modifier when defining this function and use the declare statement to let the compiler know that the function exists For example let us say this is the file utility_functions tbs public function multiply a as integer b as integer as integer the value retu...

Страница 80: ...ures When calling subroutines or functions it is often necessary to pass a certain value for processing within the procedure An example of this would be a function which calculates the sum of two values naturally such a function would need to get two arguments the values which are to be added up There are two different ways to pass arguments to such a procedure The Default Passing By Value When pa...

Страница 81: ...y reference saves the need to copy the whole string to another location in memory Here is our advice when dealing with strings it is usually better in terms of performance to pass them by reference For all other types passing by value yields better performance Strict byref argument match is now required Beginning with Tibbo Basic release 2 0 strict match is required between the type of byref argum...

Страница 82: ...they will share the same memory space because only one will be executing at any given time However sometimes procedures call other procedures This affects memory allocation As seen above the event handler on_event_1 calls procedure A which in turn calls procedure B The memory required for each procedure is listed in brackets Since on_event_1 procedure A and procedure B call each other they may not...

Страница 83: ...cal to implement necessary functionality in procedures invoked from HTML pages rather than include BASIC code directly into the body of HTML files Introduction to Control Structures Control Structures are used to choose what parts of your program to execute when to execute them and whether to repeat certain blocks of code or not and for how many iterations The two main types of control structures ...

Страница 84: ...ming 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 in the queue see System Components To resolve this a doevents statement has been provided When this statement is invoked within a procedure the execution of this procedure is interrupted The VM then handles ...

Страница 85: ...hen return control to the previous doevents the one from event handler on_event_1 The point here is that control will not be returned to on_event_1 until on_event_3 fully completes execution since on_event_3 contains a doevents statement in itself Memory Allocation When Using Doevents When a procedure utilizes doevents it means its execution gets interrupted while other procedures get control We h...

Страница 86: ...he project depicted above would be 16 bytes 11 shared bytes plus 5 exclusive bytes This is more than would have been required had we not used doevents Sharing Procedures Which Utilize Doevents Procedures which contain doevents statements as well as all procedures which call them directly or through other procedures cannot be shared between chains Let us say event handler on_event_1 calls procedure...

Страница 87: ...pen that another instance of event_1 will be found on the queue waiting to be processed If this happens this new instance will just be skipped execution will move on to the next event on the queue 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 Ti...

Страница 88: ...D s ABC will be compiled when OPTION RED 0 elif OPTION GREEN s DEF will be compiled when OPTION GREEN 1 Else s 123 will be compiled when neither RED nor GREEN endif You can also write like this If OPTION x 33 will be compiled in if OPTION evaluates to any value except 0 Will not be compiled in if OPTION evaluates to 0 endif Preprocessor directives are not strict You don t have to define something ...

Страница 89: ... and ifndef are like if but instead of evaluating an expression they simply checks if specified definition exists ifdef OPTION s X will be compiled if OPTION is defined Else s 1 will be compiled if OPTION is not defined endif ifndef is like ifdef but in reverse ifndef OPTION s X will be compiled if OPTION is not defined Else s 1 will be compiled if OPTION is defined endif 4 2 7 1 Scope of Preproce...

Страница 90: ...ings dialog Working with HTML One of the strengths of programmable is that they feature a built in webserver of course this is only true for devices that have a network interface and support 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 Here is a simple exam...

Страница 91: ...ce built in webserver can provide a convenient interface to this device in fact it is one of the best ways to allow your users to access your device remotely 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...

Страница 92: ...N HTML BODY BEGINNING OF OUTPUT br BASIC procedure starts here dim i as integer for i 1 to 10 i Foo i br next i procedure ends here br end OF OUTPUT br BODY HTML There two code fragments yet they both form one procedure For example variable i declared in the first fragment is still visible in the second fragment The fact that entire code within each HTML file is considered to be a part of a single...

Страница 93: ...sock setdata method Further information about creating HTML files with dynamic content can be found in Using HTTP part of the sock object documentation Understanding Platforms As an embedded language Tibbo Basic may find itself within many various hardware devices each such device may have different capabilities in terms of storage physical interfaces processing power and other such parameters Thu...

Страница 94: ...ta 50 gets up to 50 bytes of data into variable s ser setdata s prepares up to 50 bytes of data for sending ser send no arguments returns nothing Sends data An event of an object is something that happens to this object in reality When TiOS registers an event an event handler for it is automatically called if it exists in your source code Event handlers are simply subs with no arguments sub on ser...

Страница 95: ...tion name The name of the constant later used to refer to this constant in code value The value for the constant this can be an expression Details This statement defines an identifier and binds a constant value to it During compilation when the compiler finds an identifier it substitutes the identifier with the value given for the constant When defining a constant you can use any valid constant ex...

Страница 96: ...finition type 1 2 Optional required if arguments are present Specifies the type of the argument to be passed to the procedure ret_type Optional required for functions cannot be used for subs Used to specify the type of the return value from the procedure bounds 1 2 Optional used only when declaring variables Specifies the boundary finite size of a dimension in an array Details In large projects yo...

Страница 97: ...lt size is 255 bytes Details The dim statement creates a variable in the current scope It reserves memory space for this variable Hence as part of a dim statement you have to specify the type of the variable specifying the type also defines how much memory will be allocated for this variable When creating strings you can explicitly define their maximum size by including it in parentheses immediate...

Страница 98: ... 32 10 alternative way to make the same definition Doevents Statement Function Interrupts the current event handler and processes all events in the queue at the moment of invocation Syntax doevents Scope Global HTML and local See Also Declare Statement Details Executes events pending in the queue then returns execution to current event handler See doevents above Examples calculate sum of all array...

Страница 99: ...s a block of code If the condition while or until is included at the end of the loop after the loop keyword the block of code is executed at least once If the condition is included at the beginning of the loop after the do keyword the condition must evaluate to true for the code to execute even once Any number of exit do statements may be placed anywhere in the do loop as an alternate way to exit ...

Страница 100: ...e name for the constant in the enum value1 Optional A value associated with the constant Details Enum types can be useful for debugging purposes When you add an enum type to a watch you will see the constant name within the enum and not a meaningless number By default constants get incremental values starting from 0 for the first item You can think of this as a counter enumerating the items in the...

Страница 101: ...ithin for next or for each next loops When using exit for control is passed to the statement which is immediately after the next statement When used within nested for loops exit for transfers control to the loop which is one nested level above the loop in which exit for occurs exit function Exits the current function Execution resumes from the point where the function was originally called exit su...

Страница 102: ...red The end value for the counter once the counter reaches it execution of the for next loop stops Can be a numerical constant or a more complex expression step_number Optional Defines the intervals in which the name counter is incremented on every pass of the loop This must be a numerical constant and can be either positive or negative statement 1 2 Required Lines of code to be executed as long a...

Страница 103: ...tion used to call it etc byref Optional If present the argument immediately following this modifier will be passed by reference argument 1 2 Optional The name of the argument s passed to the function arguments must have a name which is a valid identifier This is a local identifier used to refer to these arguments within the body of the function as Optional required if arguments are specified Prece...

Страница 104: ...s not actually useful declare subtract x as byte y as byte as integer have to declare because it s invoked before its body function distance x as byte y as byte as integer if x y then distance subtract x y else distance subtract y x end if end function function subtract x as byte y as byte as integer subtract x y end function Goto Statement Function Jumps to a specific point in code marked by a la...

Страница 105: ...ys contain the same data exit sub here when arrays are not the same not_the_same place code here If Then Else Statement Function A way to conditionally execute code Syntax if expression then statement1 statement2 else statement1 statement2 end if or if expression then true_statement1 true_statement2 Scope Local and HTML See Also Select Case Statement Part Description expression Required The result...

Страница 106: ...e 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 If then else statements may be nested Currently single line if then statements cannot contain an else clause The elseif syntax is not currently supported at all even on multi line if then statements Examples if net failure 1 then if sys runmode 0 the...

Страница 107: ...eader files with declarations definitions for constants enum types etc Examples File global tbh a header file Declare Function multiply x As Byte y As Byte As Integer Const k 3 a crucially vital global constant File main tbs a source code file Include global tbh now we have access to multiply and to K Sub on_sys_init Dim result As Integer result multiply k 3 End Sub File library tbs a source code ...

Страница 108: ...ession the statements included in this case clause are executed statement 1_1 N_1 Required Statements to execute when expression 1_1 N_1 matches select_expression Optional Maintained for backwards compatibility some versions of BASIC in the past required a colon following every case expression case else Optional Precedes a block statements which is executed if neither of the earlier case clause ma...

Страница 109: ...2 ser setdata Tuesday case 3 ser setdata Wednesday case 4 ser setdata Thursday case 5 ser setdata Friday case 6 ser setdata Saturday case 7 ser setdata Sunday case else ser setdata Did you just invent a new day end select ser send end sub Sub Statement Function Used to define subs distinct units in code which perform specific tasks These never return any value Syntax public sub name byref argument...

Страница 110: ...s the data type for the argument Each argument name must be followed with a type definition even when specifying several arguments of the same type statement 1 2 Required The body of code executed within the function specifies the actual work done by the function Details Subroutines cannot be nested which is why their scope is defined as global or HTML Subroutines do not return values Subroutines ...

Страница 111: ...include any number of members and each member can be of any type Any member can also be an array or another structure Nesting of up to 8 levels is allowed i e array within a structure within a structure within and array each structure or array is one level and up to 8 levels are possible Type end type is only a declaration not a variable definition You still need to use a regular dim statement to ...

Страница 112: ...s encountered or 1 if this character was encountered dim s as string 1 input data byte by byte for as long as there is some data left to process s ser getdata 255 will input byte by byte as s only can contain a single char while len s 0 if s chr ch then wait_char 0 character encountered exit function end if s ser getdata 255 wend wait_char 1 did not encounter ch character and there is no more data...

Страница 113: ...r Types ByVal A keyword designating a way of passing arguments Appears as part of the following statements Function Statement Sub Statement For further details see Passing Arguments to Procedures Char A data type Please see Variables And Their Types Else A keyword used to denote conditions Appears as part of the following statements If Then Else Statement Select Case Statement End This keyword is ...

Страница 114: ...ic A keyword used to denote visibility Appears as part of the following statements Dim Statement Function Statement Sub Statement For further details see Understanding the Scope of Variables Short A data type Please see Variables And Their Types Step 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 c...

Страница 115: ... byte constant with a value of 1 associated with boolean variables Word A data type Please see Variables And Their Types Operators Tibbo Basic supports the following operators Operator Addition operator applies to strings as well i 1 2 this would be 3 s foo bar this would be foobar Operator Multiplication operator i 5 2 10 Operator Subtraction Operator i 20 5 15 Operator Division operator 94 86 43...

Страница 116: ...nt operator if i 5 then as an equality operator i 5 as an assignment operator AND Operator 1 Logical AND 2 Bitwise AND if i 5 AND j 10 then as a logical AND x b01011001 AND b10101011 this would be b00001001 NOT Operator 1 Logical NOT 2 Bitwise NOT if NOT b then as a logical NOT b is a boolean value x NOT b01011001 this would be b10100110 OR Operator 1 Logical OR 2 Bitwise OR if i 5 OR j 10 then as...

Страница 117: ...o 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 Example dim x as byte error C1001 invalid char 25 See Also Naming Conventions C1002 Description This error occurs when source code contains a line break inside a string literal or a character co...

Страница 118: ...tain two characters at most in which case the constant type will be word Example x abc error C1004 too many chars in constant See Also Constants C1005 Description 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 x b102 error C1005 invalid numeric constant x 10a error C1005 invalid numeric co...

Страница 119: ...d case 1 case 2 b true case 3 b false case else sys halt end select sub on_init end function error C1006 End Sub expected See Also Language Reference C1007 Description A numerical constant does not fit in any supported numerical type Example x 65536 error C1007 Constant too big x 32769 error C1007 Constant too big enum my_enum my_val1 32768 my_val2 32768 end enum error C1007 enum range is too wide...

Страница 120: ... the requested operation cannot be performed using the data types provided Example dim s as string s abc 5 error C1009 type mismatch See Also Variables And Their Types C1010 Description This error occurs when attempting to re use an identifier that is already used and thus cannot be reused in the current scope in a definition or a declaration of an enumeration type a constant a variable or a funct...

Страница 121: ...ody end sub See Also Sub Statement Function Statement C1012 Description The definition for a procedure does not match a previous declaration for that procedure a different number or type of arguments and or a return value Example declare sub x sub x i as integer error C1012 argument count mismatch see previous declaration of x end sub See Also Declare Statement Sub Statement Function Statement 132...

Страница 122: ...entifiers can refer to entities of different types labels variables procedures enumeration types constants This error occurs when you cannot use identifier of a certain type in the current statement Example dim x as integer goto x 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 dim...

Страница 123: ...0 exit while error C1016 Exit is of scope next i See Also Exit Statement C1017 Description Assignment statements must contain a value on left side of the equal sign called an l value This can be a variable an array element or a read write property and may not be a constant Example 1 x error C1017 l value expected on the left of C1018 Description Assignment statements must contain a value on right ...

Страница 124: ...r Example dim i j as integer i j 3 error C1019 j is not array See Also Introduction to Variables Constants and Scopes Arrays C1020 Description This error occurs when trying to define an array with more than 8 dimensions a maximum of 8 dimensions are allowed Example dim 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 whe...

Страница 125: ...son string copy conversion from string to number etc This error occurs when a platform does not export these functions but source code requires them Example doevents error C1022 platform does not export doevents syscall See Also Type Conversion C1023 Description The global scope may contain only declarations definitions of procedures variables enumeration types and constants This error occurs when...

Страница 126: ...er addresses are reserved for passing arguments and returning values from platform syscalls The data base address for program variables is calculated according to how much memory platform syscalls require for arguments and return values Most commonly this error means that you are trying to link object files built for different platforms See Also System Components L1002 Description This error occur...

Страница 127: ...ress and the export is a code address or vice versa L1005 Description Since all memory allocation is static recursion is not supported This error occurs whenever the linker encounters recursion direct or indirect See Also Introduction to Procedures Our Language Philosophy L1006 Description The TiOS Virtual Machine may hold up to 255 stack locations This error occurs when the linker needs to reserv...

Страница 128: ...s L1008 Description The amount of RAM needed to store variables for your project exceeds the maximum possible size for this platform In simple terms your variables take up too much space 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 Platfor...

Страница 129: ...n Windows programs such as Window Tile will work just as you would expect them to work We will concentrate on the more unique parts of the TIDE GUI Installation Requirements The recommended system requirements for TIDE are 800 MHz Intel Pentium III processor or equivalent and later Windows 98 ME 2000 XP 2003 256 MB RAM 20MB of available disk space A communication medium with your target platform s...

Страница 130: ...he Edit Mode in which you write the code for your application and the Debug Mode which is used while your code is running on the target and you are debugging it In each of these modes you may show hide or resize various interface elements The changes you make in one mode do not affect the other state I e you could display the Debug Toolbar while in Debug Mode and hide it while in Edit Mode Every t...

Страница 131: ...the two modes apart by the background color of the code editor pane When the background is white you are in Edit Mode When it s grey you are in Debug Mode Menu Bar A standard bar modeled after the classic Windows menu bar See below File Menu Edit Menu View Menu Project Menu Debug Menu Image Menu visible only when graphical resource is selected for editing Window Menu Help Menu 6 2 3 1 File Menu Ne...

Страница 132: ... current file Print Prints the current file Print Preview Check output before printing Print Setup Configure printing 1 4 Recent files Exit Quits TIDE 6 2 3 2 Edit Menu 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 ...

Страница 133: ...r Output Clears the contents of the Output pane Watch Toggles the Watch pane Call Stack Toggles the Call Stack pane Auto complete List Show an appropriate auto complete list for the current context Argument List Show a list of arguments for the current procedure call 6 2 3 4 Project Menu Settings Displays the Project Settings dialog Select Manage Target Shows the platform specific dialog used to s...

Страница 134: ... mode If the target was running it will continue running 6 2 3 5 Debug Menu Restart Reboots the target device Rebooting the device will not resume execution Once the device has finished the reboot process execution will be paused pending further debug instructions Run Begins or resumes program execution on target If switching from Edit mode this optionally compiles and uploads the project when nee...

Страница 135: ... x8 x16 magnification levels are available Zoom Out Selects lower magnification x1 x2 x4 x8 x16 magnification levels are available Grid Toggles image grid visible invisible Flip H Mirrors entire image or selected rectangular area if selection is made horizontally Flip V Mirrors entire image or selected rectangular area if selection is made vertically Rotate Right 90 Rotates entire image or selecte...

Страница 136: ...lowing toolbars Project Toolbar Debug Toolbar Image Editor Toolbar visible only when graphical resource is selected for editing Tool Properties Toolbar visible only when graphical resource is selected for editing contents depend on the selected tool 6 2 4 1 Project Toolbar New Project Displays the New Project dialog Open Project Opens an existing project Save Project Saves all modified files on th...

Страница 137: ... Rebooting the device will not resume execution Once the device has finished the reboot process execution will be paused pending further debug instructions Run Begins or resumes program execution on target If switching from Edit mode this optionally compiles and uploads the project when needed Pause Pauses program execution Covered under Target States above Stop Build Upload Debug Stops building u...

Страница 138: ...ool Erases portions of the image paints with background color Text Tool Adds text to the image Line Tool Draws straight lines Rectangle Tool Draws rectangles Ellipse Tool Draws ellipses Eyedropper Tool Picks the color off the image left click over the image to pick the fore color right click to pick the background color Zoom Tool Changes the zoom level magnification x1 x2 x4 x8 x16 zoom levels are...

Страница 139: ...f selection is made horizontally Flip Vertically Mirrors entire image or selected rectangular area if selection is made vertically Rotate Left 90 Rotates entire image or selected rectangular area if selection is made 90 degrees counter clockwise Rotate Right 90 Rotates entire image or selected rectangular area if selection is made 90 degrees clockwise Paint Tool Properties Inversion Mode Toggles p...

Страница 140: ...with Font Size Selects the size of the font Bold Toggles bold attribute for the font on off Italic Toggles italic attribute for the font on off Underline Toggles underline attribute for the font on off Left Selects left alignment for the text result is visible with multi line text only Center Selects center alignment for the text result is visible with multi line text only Right Selects right alig...

Страница 141: ... filling inversion mode effect is applied with enabled Size Border width irrelevant for solid rectangles Corner rounding Defines the radius of rectangle corners Ellipse Tool Properties Inversion Mode Toggles ellipse tool s inversion mode on off When inversion is OFF the ellipse s border will always be drawn in the fore ground color and filling for filled ellipses will always be done with backgroun...

Страница 142: ...ng long operations uploading binary etc Communication State indicator Covered under Target States above Target State indicator Covered under Target States above Timer Covered under Code Profiling above Cursor location Lines and columns CAP NUM SCRL Status indicators for Caps Lock Num Lock and Scroll Lock Dialogs Not all dialogs are reviewed only the ones which are not self explanatory In this sect...

Страница 143: ...BASIC User Manual 2000 2008 Tibbo Technology Inc 6 2 6 1 Project Settings This dialog has been covered under Project Settings above 6 2 6 2 New Project This dialog has been covered under Starting a New Project above 38 10 ...

Страница 144: ...Graphic File Properties Dialog This dialog has been covered under Adding Removing and Saving Files above Panes 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 6 2 7 1 Call Stack 18 18 117 130 128 129 129 130 130 ...

Страница 145: ... 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 6 2 7 3 Project The Project pane contains two tabs Browser and Files Browser The Browser tab has been covered under Using the Project Browser and under The Watch above 31 129 130 22 33 ...

Страница 146: ...ve 6 2 7 4 Watch The Watch pane has been covered under The Watch above 6 2 7 5 Colors 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 18 33 ...

Страница 147: ...is not implemented i e doesn t have a body Variables see Introduction to Variables Constants and Scopes Grayed if the variable is not defined Glossary of Terms Below are several key definitions for terms used throughout the text Compilation Unit A single file containing source code to be processed by the compiler Projects may contain many compilation units Under Tibbo Basic BASIC source files tbs ...

Страница 148: ...sted under Keywords above Label An identifier marking the beginning of a block of code which will then be called using a Goto Statement Labels are declared in code by writing their name followed by a colon on a single line Linker A software program processing the output of the compiler to look for any cross references between the units If compilation unit A calls a procedure which is in compilatio...

Страница 149: ...Platforms This section contains specifications for all platforms includes into the current documentation Each platform supports a number of functions syscalls and objects Actual functions and object description is not included into each platform s spec Instead they are documented in the Function Reference and Object Reference sections while Platform Specifications section only contains the lists o...

Страница 150: ...ytes Variable memory RAM 20 480 bytes EEPROM memory STOR 2048 bytes of which 8 bytes are occupied by MAC address of the device See Platform dependent programming information for details 8 1 1 2 Supported Variabled Types This platform supports the following variable types Byte Word Char Short integer Boolean User defined structures User defined enumeration types For general type description see Var...

Страница 151: ...erface sock currentinterface Ethernet net object controls Ethernet interface Serial ser object supports 4 serial channels each channel can work in the UART Wiegand and clock data modes excludes ser redir Input output io object handles I O lines ports and interrupts only includes io num and io state EEPROM stor object facilitates access to the EEPROM memory excludes offset ROM data romfile object p...

Страница 152: ...te of DTR pin is opposite to what is set through the io state property 4 PL_IO_NUM_4_CTS Selects general purpose I O line 4 This is also a CTS input of serial port 0 On EM202 and EM200 works as input output Cannot be set through io state when ser flowcontrol 1 ENABLED On EM202 EV and DS202 works as input only and the actual state of CTS pin is opposite to what is read through the io state property...

Страница 153: ...ernal signal is driving it LOW or vise versa If the line is driven LOW internally or externally resulting state if the line is LOW For the hardware savvy reader output drivers of I O lines on this platform are implemented as open collector output with weak pull up resistor 20K Remapping of I O lines of the serial port is not possible All lines of the serial port TX W1out dout output RX W1in din in...

Страница 154: ...next time the device boots up it will start using this new address By default the area storing MAC address is not accessible to your application the stor base property takes care of that Unless you change it this property specifies that your application s storage area starts at address 9 counting from 1 To change MAC set the stor base to 1 MAC address data in the EEPROM has a certain formatting yo...

Страница 155: ...byte or error in checksum calculation the device will ignore it and boot up with default MAC which is 0 1 2 3 4 100 Available network interfaces This platform only has one network interface the Ethernet port Miscellaneous Sys object does not support the sys onsystimerperiod property and the on_sys_timer event generation period is fixed at 0 5 seconds Beginning with V2 0 sock redir and ser redir me...

Страница 156: ...t controls Ethernet port Wln handles Wi Fi interface only available on the EM1000W platform requires GA1000 add on module Ser in charge of serial ports UART Wiegand and clock data modes Io handles I O lines ports and interrupts Lcd controls graphical display panels several types supported Kp scans keypads of matrix and binary types Rtc keeps track of date and time Fd manages flash memory file syst...

Страница 157: ...e TX 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 This constant can be used as a base for all other sockets i e in expressions like sock redir PL_REDIR_SOCK0 f 7 PL_REDIR_SOCK1 Redirects RX data of the serial port or socket ...

Страница 158: ...king as an output Certain lines automatically become inputs and outputs in certain modes of operation see below for details Enum pl_io_num includes the following constants 0 PL_IO_NUM_0 General purpose I O line 0 P0 0 1 PL_IO_NUM_1 General purpose I O line 1 P0 1 2 PL_IO_NUM_2 General purpose I O line 2 P0 2 3 PL_IO_NUM_3 General purpose I O line 3 P0 3 4 PL_IO_NUM_4 General purpose I O line 4 P0 ...

Страница 159: ...e 30 P3 6 31 PL_IO_NUM_31 General purpose I O line 31 P3 7 32 PL_IO_NUM_32 General purpose I O line 32 P4 0 33 PL_IO_NUM_33 General purpose I O line 33 P4 1 34 PL_IO_NUM_34 General purpose I O line 34 P4 2 35 PL_IO_NUM_35 General purpose I O line 35 P4 3 36 PL_IO_NUM_36 General purpose I O line 36 P4 4 37 PL_IO_NUM_37 General purpose I O line 37 P4 5 38 PL_IO_NUM_38 General purpose I O line 38 P4 ...

Страница 160: ... automatically 2 When a serial port is in the UART mode ser mode 0 PL_SER_MODE_UART this line is automatically configured to be an output when the serial port is enabled ser enabled 1 YES and returns to the previous input output and high low state when the serial port is closed ser enabled 0 NO When a serial port is in the Wiegand or clock data mode ser mode 1 PL_SER_MODE_WIEGAND or ser mode 2 PL_...

Страница 161: ..._SOCK_INTERFACE_NET default Ethernet interface 2 PL_SOCK_INTERFACE_WLN Wi Fi interface 8 1 2 4 Platform dependent Programming Information This section contains miscellaneous information pertaining to the EM1000 W 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 o...

Страница 162: ... your circuitry may occur if this happens You can remap RTS W0out cout and CTS W0 1in cin lines of the serial port Two lines of the serial port RTS W0out cout output and CTS W0 1in cin input can be reassigned remapped to other I O pins of the device This is done through ser rtsmap and ser ctsmap properties By default the mapping of these two lines is different for each serial port See Enum pl_io_n...

Страница 163: ...s There is a PLL On the EM1000 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 The clock frequency affects all aspects of device operation that rely on this clock Naturally program execution ...

Страница 164: ...MAC3 MAC 4 MAC5 Checksum Byte at address 1 must be set to 6 this means that 6 byte of data follow MAC address consists of 6 bytes Addresses from 2 to 7 carry actual MAC data Address 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...

Страница 165: ...e between the EM1202 and EM1202W platforms is that the EM1202W additionally includes the wln 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 Supported Variable Types common for T1000 based devices LED signals common for all devices Debug...

Страница 166: ...r this platform Enum pl_io_num a list of constants that define available I O lines 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 The following objects support buffers and buffer redirection on...

Страница 167: ...R_SOCK9 Redirects RX data of the serial port or socket to the TX buffer of socket 9 16 PL_REDIR_SOCK10 Redirects RX data of the serial port or socket to the TX buffer of socket 10 17 PL_REDIR_SOCK11 Redirects RX data of the serial port or socket to the TX buffer of socket 11 18 PL_REDIR_SOCK12 Redirects RX data of the serial port or socket to the TX buffer of socket 12 19 PL_REDIR_SOCK13 Redirects...

Страница 168: ... general purpose I O line 6 P0 6 PL_IO_NUM_7 Selects general purpose I O line 7 P0 7 PL_IO_NUM_8_RX0 Selects general purpose I O line 8 P1 0 This line is also the RX W1in din input of the serial port 0 PL_IO_NUM_9_TX0 Selects general purpose I O line 9 P1 1 This line is also the TX W1out dout output of the serial port 0 PL_IO_NUM_10_RX1 Selects general purpose I O line 10 P1 2 This line is also th...

Страница 169: ...cally configured to be an input when this serial port is enabled ser enabled 1 YES and returns to the previous input output and high low state when this serial port is closed ser enabled 0 NO When a serial port is in the Wiegand or clock data mode ser mode 1 PL_SER_MODE_WIEGAND or ser mode 2 PL_SER_MODE_CLOCKDATA the line has to be configured as input by the application this will not happen automa...

Страница 170: ...t of network interfaces supported by the EM1202 W The EM1202 and EM1202W platforms differ in that the EM1202W has a W Fi interface which the EM1202 does not and the pl_sock_interfaces reflects this EM1202 platform 0 PL_SOCK_INTERFACE_NULL Null empty interface 1 PL_SOCK_INTERFACE_NET default Ethernet interface EM1202W platform 0 PL_SOCK_INTERFACE_NULL Null empty interface 1 PL_SOCK_INTERFACE_NET de...

Страница 171: ... io num PL_IO_NUM_5 select the line io enabled YES enable output driver you need to do this only once io state LOW set the state Make sure that your external circuitry does not attempt to drive the I O lines that have their output buffers enabled Severe damage to the device and or your circuitry may occur if this happens You can remap RTS W0out cout and CTS W0 1in cin lines of the serial port Two ...

Страница 172: ... sent out Therefore after the CTS state becomes cannot transmit the device can still send out up to 16 characters There is a PLL On the EM1202 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 ...

Страница 173: ... if you want the MAC to be recognized by the firmware TiOS Here is the format Byte1 Byte2 Byte3 Byte4 Byte5 Byte 6 Byte7 Byte8 6 MAC0 MAC1 MAC2 MAC3 MAC 4 MAC5 Checksum Byte at address 1 must be set to 6 this means that 6 byte of data follow MAC address consists of 6 bytes Addresses from 2 to 7 carry actual MAC data Address 8 stores the checksum which is calculated like this 255 modulo8_sum_of_add...

Страница 174: ...difference between the EM1206 and EM1206W platforms is that the EM1206W additionally includes the wln 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 Supported Variable Types common for T1000 based devices LED signals common for all devi...

Страница 175: ...or this platform Enum pl_io_num a list of constants that define available I O lines 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 The following objects support buffers and buffer redirection o...

Страница 176: ...irects RX data of the serial port or socket to the TX buffer of socket 9 16 PL_REDIR_SOCK10 Redirects RX data of the serial port or socket to the TX buffer of socket 10 17 PL_REDIR_SOCK11 Redirects RX data of the serial port or socket to the TX buffer of socket 11 18 PL_REDIR_SOCK12 Redirects RX data of the serial port or socket to the TX buffer of socket 12 19 PL_REDIR_SOCK13 Redirects RX data of...

Страница 177: ...his line is also the RX W0 1in din input of the serial port 3 and the interrupt line 6 7 PL_IO_NUM_7_TX3_INT7 2 General purpose I O line 7 P0 7 This line is also the TX W1out dout output of the serial port 3 and the interrupt line 7 8 PL_IO_NUM_8 General purpose I O line 8 P1 0 9 PL_IO_NUM_9 General purpose I O line 9 P1 1 10 PL_IO_NUM_10 General purpose I O line 10 P1 2 11 PL_IO_NUM_11 General pu...

Страница 178: ...ains the list of constants that refer to interrupt I O lines available on the EM1206 W Interrupt lines are mapped onto general purpose I O lines Interrupt line 0 corresponds to I O line 0 interrupt line 1 to I O lines 1 and so on Keep in mind that for an interrupt line to work you need to configure a corresponding I O line as input Do this through the io num property of the io object Enum pl_int_n...

Страница 179: ...ines as inputs or outputs On the EM1206 W you need to explicitly enable or disable the output driver of each I O line controlled by the io object The io enabled property allows you to do this When the driver is enabled ser enabled 1 YES and you read the state of the pin you will get back the state of your own output buffer To turn the line into an input switch the output buffer off ser enabled 0 N...

Страница 180: ... as output 2 Requires configuratio n as input 2 1 PL_SER_MODE_WIE GAND Requires configuratio n as output Requires configuratio n as input 2 PL_SER_MODE_CLO CKDATA Notes 1 When This line does not require configuration it will be configured automatically as input or output when the port is opened When the port is closed the line will return to the input output and high low state it had before the po...

Страница 181: ...urrpll 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 a MAC address of the device On power up the MAC address is read out from the EEPROM and programmed into the Ethernet controller You can always check current MAC through the net mac read only property of the net object but there is no direc...

Страница 182: ...ata wrong first byte or error in checksum calculation the device will ignore it and boot up with default MAC which is 0 1 2 3 4 100 Available network interfaces The EM1206 platform only has one network interface the Ethernet port The sock allowedinterfaces property refers to this interface as NET The EM1206W platform supports two network interfaces the Ethernet interface and Wi Fi interface NET an...

Страница 183: ...ilitates access to resource files fixed data Pat plays patterns on up to five LED pairs Button monitors MD line setup button Sys in charge of general device functionality 8 1 5 3 Platform dependent Constants The following constant lists are platform specific Enum pl_redir a list of constants that define buffer redirection shorting for this platform Enum pl_io_num a list of constants that define av...

Страница 184: ...socket 2 9 PL_REDIR_SOCK3 Redirects RX data of the serial port or socket to the TX buffer of socket 3 10 PL_REDIR_SOCK4 Redirects RX data of the serial port or socket to the TX buffer of socket 4 11 PL_REDIR_SOCK5 Redirects RX data of the serial port or socket to the TX buffer of socket 5 12 PL_REDIR_SOCK6 Redirects RX data of the serial port or socket to the TX buffer of socket 6 13 PL_REDIR_SOCK...

Страница 185: ...the following constants 0 PL_IO_NUM_0_RX0_INT0 1 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 1 PL_IO_NUM_1_TX0_INT4 2 General purpose I O line 1 P0 1 This line is also the TX W1out dout output of the serial port 0 and the interrupt line 4 2 PL_IO_NUM_2_RX1_INT1 1 General purpose I O line 2 P0 2 This line is also the RX W0 1i...

Страница 186: ... line has to be configured as output by the application this will not happen automatically Enum pl_int_num Enum pl_int_num contains the list of constants that refer to interrupt I O lines available on this platform Interrupt lines are mapped onto general purpose I O lines Keep in mind that for an interrupt line to work you need to configure a corresponding I O line as input Do this through the io ...

Страница 187: ...ed 0 NO This will allow you to sense the state of the external signal applied to the I O line io num PL_IO_NUM_4 just to select some line as an example io enabled NO now the output driver is off x io state read line state into x When the device boots up all pins are configured as inputs If you want to use any particular I O pin as an output you need to enable the output driver first io num PL_IO_N...

Страница 188: ...terface 0 PL_SER_SI_FULLDUPLEX and ser flowcontrol 1 ENABLED the device is monitoring its CTS input to see if attached serial device is ready to receive more data If the CTS state changes to 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 ...

Страница 189: ... there is no direct way to change it Instead you can change the MAC address data in the EEPROM Then next time the device boots up it will start using this new address By default the area storing MAC address is not accessible to your application the stor base property takes care of that Unless you change it this property specifies that your application s storage area starts at address 9 counting fr...

Страница 190: ...ncorrect MAC data wrong first byte or error in checksum calculation the device will ignore it and boot up with default MAC which is 0 1 2 3 4 100 Available network interfaces The DS1202 platform only has one network interface the Ethernet port The sock allowedinterfaces property refers to this interface as NET Also see the pl_sock_interfaces enum which is used by sock targetinterface and sock curr...

Страница 191: ... to five LED pairs Button monitors MD line setup button Sys in charge of general device functionality 8 1 6 3 Platform dependent Constants The following constant lists are platform specific Enum pl_redir a list of constants that define buffer redirection shorting for this platform Enum pl_io_num a list of constants that define available I O lines Enum pl_int_num a list of constants that define ava...

Страница 192: ... socket to the TX buffer of socket 3 10 PL_REDIR_SOCK4 Redirects RX data of the serial port or socket to the TX buffer of socket 4 11 PL_REDIR_SOCK5 Redirects RX data of the serial port or socket to the TX buffer of socket 5 12 PL_REDIR_SOCK6 Redirects RX data of the serial port or socket to the TX buffer of socket 6 13 PL_REDIR_SOCK7 Redirects RX data of the serial port or socket to the TX buffer...

Страница 193: ...line 0 P0 0 This line is also the RX W1in din input of the serial port 0 and the interrupt line 0 1 PL_IO_NUM_1_TX0_INT1 2 General purpose I O line 1 P0 1 This line is also the TX W1out dout output of the serial port 0 and the interrupt line 1 2 PL_IO_NUM_2_RX1_INT2 1 General purpose I O line 2 P0 2 This line is also the RX W0 1in din input of the serial port 1 and the interrupt line 2 3 PL_IO_NUM...

Страница 194: ...losed ser enabled 0 NO When a serial port is in the Wiegand or clock data mode ser mode 1 PL_SER_MODE_WIEGAND or ser mode 2 PL_SER_MODE_CLOCKDATA the line has to be configured as output by the application this will not happen automatically Enum pl_int_num Enum pl_int_num contains the list of constants that refer to interrupt I O lines available on this platform Interrupt lines are mapped onto gene...

Страница 195: ... to explicitly enable or disable the output driver of each I O line controlled by the io object The io enabled property allows you to do this When the driver is enabled ser enabled 1 YES and you read the state of the pin you will get back the state of your own output buffer To turn the line into an input switch the output buffer off ser enabled 0 NO This will allow you to sense the state of the ex...

Страница 196: ... This line does not require configuration it will be configured automatically as input or output when the port is opened When the port is closed the line will return to the input output and high low state it had before the port was opened 2 Please remember that you need to configure the I O pin to which this line of the serial port is currently mapped Each serial port has 16 bytes of send FIFO Whe...

Страница 197: ... are reserved for storing a MAC address of the device On power up the MAC address is read out from the EEPROM and programmed into the Ethernet controller You can always check current MAC through the net mac read only property of the net object but there is no direct way to change it Instead you can change the MAC address data in the EEPROM Then next time the device boots up it will start using thi...

Страница 198: ...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 If you write incorrect MAC data wrong first byte or error in checksum calculation the device will ignore it and boot up with default MAC which is 0 1 2 3 4 100 Available network interfaces The DS1206 platform only has one network interface the Ethernet port The sock allowedinterfaces property refers to this i...

Страница 199: ... numerical string Lbin unsigned 32 bit numeric value dword binary numerical string Str unsigned 16 bit numeric value word decimal numerical string Stri signed 16 bit numeric value short decimal numerical string Lstr unsigned 32 bit numeric value dword decimal numerical string Lstri signed 32 bit numeric value long decimal numerical string Hex unsigned 16 bit numeric value word hexadecimal numerica...

Страница 200: ...omprised of green and red status LEDs SG and SR LEDs or lines the second pair of green and yellow Ethernet status LEDs EG and EY LEDs or lines Status LEDs have multiple functions 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 Tib...

Страница 201: ...ccupy minimum resources on the target Allow for fast and efficient debug communications The resulting debug communications system Does not even require a proper IP address on the target side Allows you to freely change the IP address of the target while debugging Occupies a single UDP port 65535 on the target and even this port can be used by your program in most cases Your PC running TIDE sends d...

Страница 202: ...t correct MAC address of your target You can input the MAC address directly or click Browse to bring up the Device Explorer dialog Customize Platform dialog Pressing Customize button brings up the Customize Platform dialog Your options depend on the platform and usually include enabling disabling certain objects For example on the EM1000 platform you can enable disable display support lcd object f...

Страница 203: ...e released for it The target is running TiOS and no BASIC application is in memory The target is running TiOS a BASIC application is in memory and is running The target is running TiOS a BASIC application is in memory and is stopped The target is running TiOS a BASIC application is in memory and is paused for debugging MAC This is the current MAC address of the target It can be changed IP The curr...

Страница 204: ...computer COM1 COM2 etc Abort Aborts the current operation Operations in this dialog do not time out you must abort them manually This is beneficial since if there is any problem you may troubleshoot it and once resolved operation will just resume normally you will not have to restart a complex process or restore some state Select This button is only visible when accessing the dialog from within TI...

Страница 205: ...P datagrams Of course once you upload a device with the TiOS firmware it is no longer a Device Server So you cannot see it under DS Manager You could program it so it would respond to DS Manager but by default it is a clean slate and does not respond to DS Manager broadcasts Function Reference Function reference section is a repository for all functions syscalls that have ever been created The pla...

Страница 206: ...Returns 0 VALID if the floating point value is OK and 1 INVALID if the floating point value is invalid Syntax cfloat byref num as real as valid_invalid See Also strtof ftostr Part Description num Variable to check Details Floating point calculations can lead to invalid result INF INF errors as per IEEE specification When your application is in the debug mode you will get a FPERR exception if such ...

Страница 207: ...asciicode as byte as string See Also Asc Part Description asciicode ASCII code of the character to return Details It is also possible to use this function within string definitions as shown in the example below Examples dim x as byte dim s as string x 49 s chr x result will be 1 s FooBar chr 13 would add a carriage return to the end of the string Date Function Function Returns the date for a given...

Страница 208: ...Part Description year The year is supplied as offset from year 2000 so it is 6 for year 2006 Acceptable year range is 0 99 2000 2099 month 1 12 for January December date Date of the month Details If any input parameter is illegal year exceeds 99 month exceeds 12 etc this syscall will return 65535 This error value cannot be confused with an actual valid day number since the maximum day number recog...

Страница 209: ...s now s will be equal to 192 168 100 40 Ddval Function Function Converts dot decimal string into dot decimal value Syntax ddval byref str as string as string Returns A string of binary values See Also ddstr Part Description str Dot decimal string to be converted into a string of binary values This string should comprise one or more dot separated decimal values in the 0 255 range Values that exceed...

Страница 210: ...antissa exponent format 2 FTOSTR_MODE_PLAIN Use plain format not mantissa exponent representation rnd Number of digits to round the result to total number of non zero digits in the integer and fractional part of mantissa Details Ftostr function offers much more control over the format of the output string compared to similar functions found on other systems For starters you can select whether you ...

Страница 211: ...esult will be 1234567 13 s ftostr r1 FTOSTR_MODE_AUTO 2 result will be 1200000 s r1 fstr will be used result will be 1234567 125 Hex Function Function Converts unsigned 16 bit numeric value word into its HEX string representation Syntax hex num as integer as string See Also str lstr stri lstri bin lbin lhex val lval Part Description num Value to convert Details Standard h prefix is added at the be...

Страница 212: ...dest_str string at the insert position pos Returns the new length of dest_str Syntax insert byref dest_str as string pos as byte byref insert_str as string as byte See Also Part Description insert_str The string to insert pos Insert position in the dest_str dest_str The string to insert into Details This is an insert with overwrite meaning that the insert_str will overwrite a portion of the dest_s...

Страница 213: ...n 1 sourcestr Source string in which the substring is to be found substr Substring to search for within the source string num Occurrence number of the substr counting from 1 Details This function returns position in a string or zero if the Nth occurrence of the substring is not found Examples x substr 3 ABCABCDEABC12 BC 2 result will be 10 Lbin Function Function Converts unsigned 32 bit numeric va...

Страница 214: ...e as string See Also Right Mid Part Description sourcestr String from which to take len leftmost characters len Number of characters to take Details Examples ss left ABCDE 3 result will be ABC Len Function 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 calcu...

Страница 215: ...s as string s hex 65536 result will be h10000 Lstr Function Function Converts unsigned 32 bit numeric value dword into its decimal string representation Syntax lstr byref num as dword as string See Also str stri lstri bin lbin hex lhex val lval Part Description num Value to be converted to string Details Can be invoked implicitly through the string_var dword_var expression see example below Compil...

Страница 216: ...onverted to string Details Can be invoked implicitly through the string_var long_var expression see example below Compiler is smart enough to pre calculate constant only expressions involving implicit use of lstri function Examples dim l as long dim s as string l 5123 s lstri l explicit invocation s l implicit invocation s lstri 20 will be calculated at compilation no actual lstri function invokat...

Страница 217: ...byref input_hash as string md5_mode as md5_modes total_len as word as string Returns 16 character hash string an empty string when invalid str or input_hash argument was detected See Also sha1 Part Description str String containing the next portion of the input data to generate MD5 hash on When md5_mode 0 MD5_UPDATE this string must be 64 128 or 192 characters in length Any other length will resul...

Страница 218: ...of any size see the example below Examples Dim s hash As String simple calculation on a short string s Sting to calculate MD5 on hash md5 s MD5_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 Len s 192 hash md5 s hash MD5_UPDATE 0 s romfile getdata 192 Wend hash md5 s hash MD5_FINISH romfile size l...

Страница 219: ...ion hours An hour value from 0 to 23 hours A minute value from 0 to 59 Details If any input parameter is illegal hours exceeds 23 minutes exceeds 59 etc this syscall will return 65535 This error value cannot be confused with an actual valid minute number since the maximum minute number cannot exceed 1439 Examples w mincount 14 00 result will be 840 Minutes Function Function Returns the minutes val...

Страница 220: ...e month for a given day number Syntax month daycount as word as pl_months Returns One of pl_months constants 1 PL_MONTH_JANUARY January 2 PL_MONTH_FEBRUARY February 3 PL_MONTH_MARCH March 4 PL_MONTH_APRIL April 5 PL_MONTH_MAY May 6 PL_MONTH_JUNE June 7 PL_MONTH_JULY July 8 PL_MONTH_AUGUST August 9 PL_MONTH_SEPTEMBER September 10 PL_MONTH_OCTOBER October 11 PL_MONTH_NOVEMBER November 12 PL_MONTH_DE...

Страница 221: ... byte as string See Also Part Description len Length of the string to generate Details Right Function Function Returns len rightmost characters of a string sourcestr Syntax right byref sourcestr as string len as byte as string See Also Left Mid Part Description sourcestr String from which to take len rightmost characters len Number of characters to take Details Examples s right ABCDE 3 result will...

Страница 222: ... the result of SHA1 calculation on the previous data portion for the second and all subsequent portions of data The result of sha1 is always 20 characters long so passing the string of any other length except 0 see above will result in error and this function will return an empty string sha1_mode 0 SHA1_UPDATE Set this mode for all data portions except the last one 1 SHA1_FINISH Set this mode for ...

Страница 223: ...ord into its decimal string representation Syntax str num as word as string See Also lstr stri lstri bin lbin hex lhex val lval Part Description num Value to be converted to string Details Can be invoked implicitly through the string_var word_var expression see example below Compiler is smart enough to pre calculate constant only expressions involving implicit use of str function Examples dim w as...

Страница 224: ...BCABCA Stri Function Function Converts signed 16 bit numeric value short into its decimal string representation Syntax stri num as integer as string See Also str lstr lstri bin lbin hex lhex val lval Part Description num Value to be converted to string Details Can be invoked implicitly through the string_var short_var expression see example below Compiler is smart enough to pre calculate constant ...

Страница 225: ...m calculation Examples w strsum 012 will return 147 48 49 50 Strtof Function Function Converts string representation of a real value into a real value Syntax strtof byref str as string as real See Also ftostr str val Part Description str String to convert Details You must keep in mind that floating point calculations are inherently imprecise Not every value can be converted into its exact floating...

Страница 226: ...ry and h hexadecimal prefixes Can be invoked implicitly through the word_var string_var expression see example below Compiler is smart enough to pre calculate constant only expressions involving implicit use of val function Beginning with release 2 0 this function also plays the role of vali function which has been removed Examples dim w as word dim sh as short dim s as string s hF222 w val s expl...

Страница 227: ...AY Sunday See Also year month date daycount hours minutes mincount Part Description daycount Day number Base date for the day count is 1 JAN 2000 this is day 0 Details Examples dim w as pl_days_of_week w weekday 0 result will be PL_DOW_SATURDAY the was the day of the week for the 1st of January 2000 Year Function Function Returns the year for a given day number Syntax year daycount as word as byte...

Страница 228: ...system object that loosely combines general system stuff such as initialization boot event buffer management system timer PLL mode and some other miscellaneous properties and methods 8 3 1 1 Overview Here you will find On_sys_init boot event Buffer Management System Timer PLL Management Serial Number Miscellaneous stuff such as how to halt execution reboot check firmware version On_sys_init Event ...

Страница 229: ...ple the ser rxbuffrq method requests buffer memory for the RX buffer of one of the serial ports Similar methods exist for all other buffers of all objects that require buffer memory Note that actual memory allocation does not happen at this stage only your requests are collected After all requests have been made actual memory allocation is performed by using the sys buffalloc method This allocates...

Страница 230: ...n your system in total This is defined by the amount of physical variable memory RAM available minus memory required to store your project s variables so as your project grows available buffer memory shrinks The sys freebuffpages read only property tells you the amount of free not yet allocated buffer pages Here is an example in which we allocate memory equally between the TX and RX buffers of fou...

Страница 231: ...s this wend The above example does not represent best coding style Generally speaking this is not a great programming but sometimes you just have to wait in a cycle 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...

Страница 232: ...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 Sys serialnum R O property returns the entire 128 byte serial number or an empty string if the flash IC is of older type and does not have security register Sys setserialnum method is used to set...

Страница 233: ... what caused the most recent reset experienced by your device 8 3 1 2 Properties Methods Events This section provides an alphabetical list of all properties methods and events of the sys object Buffalloc Method Function Allocates buffer memory as previously requested by buffrq methods of individual objects such as ser rxbuffrq Syntax sys buffalloc Returns See Also sys totalbuffpages sys freebuffpa...

Страница 234: ...change only takes place after you self reset the device using sys reboot method or the device self resets due to some other reason for instance there is a self reset after a new BASIC application upload or when you hit restart button in TIDE External resets power up and RST pin reset reset button reset set the PLL to default state typically ON On some devices there is a hardware jumper that define...

Страница 235: ...L will be on the device will emerge from reset at maximum speed x8 faster than low speed Details Actual PLL mode change only takes place after you self reset the device using sys reboot method or the device self resets due to some other reason for instance there is a self reset after a new BASIC application upload or when you hit restart button in TIDE External resets power up and RST pin reset re...

Страница 236: ...on is PAUSED in debug mode New in V1 2 If the platform does not support the sys onsystimerperiod property then the interval of this event generation is fixed at 0 5 seconds If the platform does support this property then the period is adjustable Onsystimerperiod Property Selected Platforms Only Function New in V1 2 Sets returns the period for the on_sys_timer event generation expressed in 10ms int...

Страница 237: ...ELEASE debugging is not possible application execution starts immediately after device powers up Severe errors such as divizion by zero are ignored and do not stop execution 1 PL_SYS_MODE_DEBUG debug mode in which it is possible to cross debug the application under the control of TIDE software Application execution is not started automatically after the power up Severe errors such as divizion by z...

Страница 238: ...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 For the method to work the input string must be exactly 64 bytes in length otherwise 1 NG will be returned The security register can only be programmed once Attempting to program it again will fail again with 1 NG code Note that using this method disrupts the operati...

Страница 239: ...second intervals elapsed since the device powered up Type Word Value Range 0 65535 See Also on_sys_timer Details Once this timer reaches 65535 it rolls over to 0 Totalbuffpages R O Property Function Returns the total amount of memory pages available for buffers one page 256 bytes Type Byte Value Range 0 255 See Also sys buffalloc sys freebuffpages Details Calculated as total available variable mem...

Страница 240: ... RX and transmit TX buffer sizes for optimal RAM utilization Data grouping in the RX buffer based on intercharacter delay gap between two consecutive arriving characters and amount of data in the buffer Optional automatic port disabling when a data group has been received Buffer shorting feature for fast data exchange between the ser object and other objects such as the sock object that support st...

Страница 241: ...plication The logical lines available are The TX W1out dout output line The RX W1in din input line The RTS W0out cout output line The CTS W0 1in cin input line TX W1out dout and RX W1in din lines always have fixed position in the device i e they cannot be re mapped to a different I O pin RTS W0out cout and CTS W0 1in cin lines can be re mapped on select devices Also depending on the device and the...

Страница 242: ... with no parity or even odd mark or space parity configuration Additionally you can specify the number of bits in each character 7 or 8 The serial port takes care of parity calculation automatically When parity bit is enabled it will automatically calculate parity bit value for each character it transmits When receiving the serial port will correctly process incoming characters basing on the speci...

Страница 243: ...t is closed or the RX buffer has less than 64 bytes of free space left Figure below illustrates RTS operation All diagrams show TTL serial signals If you are dealing with the lines of the RS232 port you will see all signals in reverse The CTS input is used by the serial port to check if attached serial device is able to accept the data The serial port will only start to send the data when the CTS ...

Страница 244: ...ial port In the half duplex mode the RTS output is used to control data transmission direction You can select the polarity of the direction control signal i e which state will serve as data in direction and which as data out direction see Serial Settings When the serial port has no data to transmit the TX buffer is empty it is always ready to receive the data so the RTS line is in the data in stat...

Страница 245: ...a transmission is shown below There are two data lines W0 and W1 Negative pulse on the W0 line represents data bit 0 Negative pulse on the W1 line represents data bit 1 There is no standard Wiegand timing so pulse widths as well as inter gap widths wary greatly between devices Averagely pulse width is usually in the vicinity of 100uS microseconds while the inter pulse gap is usually around 20 100m...

Страница 246: ...s raw data Similarly before sending out Wiegand data your application needs to prepare this data in the desired format the serial object itself will output any data stream How the Wiegand data is stored in the RX and TX buffers of the serial port When in the Wiegand mode each data byte in the TX or RX buffer of the serial port represents one bit of Wiegand data This bit is recorded in the least si...

Страница 247: ...you will get away with using a single 74HC00 IC The serial port does not require an incoming Wiegand data stream to adhere to any strict timing The port is simply registering high to low transitions on the W0 1in line When such transition is detected the port checks the state of W1 line If the line is HIGH data bit 0 is registered when the line is low data bit 1 is registered The end of Wiegand tr...

Страница 248: ...ch as non motorized magnetic card readers output the data at variable speeds depending on how fast the user actually swipes the card The magstripe interface only differs from the clock data interface in that it has a third line card present This line goes LOW before the data transmission and goes back to HIGH after the transmission is over The serial port does not require the card present line for...

Страница 249: ...aximum flexibility and also to maintain the data processing style used by the Wiegand interface the serial port leaves the task of converting between the raw and actual data to your application The serial port only sends and receives raw data without checking or transforming its contents How the clock data stream is stored in the RX and TX buffers of the serial port When in the clock data mode eac...

Страница 250: ...ansition is detected the port checks the state of the data line If the line is HIGH data bit 0 is registered when the line is low data bit 1 is registered The end of clock data transmission is identified by timeout the serial port has a special property for that called intercharacter delay see Serial Settings Another property auto close can be used to disable the serial port after the delay has be...

Страница 251: ...your platform Thus when an event handler for the serial port object is entered the port selector is automatically switched to the port number on which the event has occurred sub on_ser_data_arrival dim s as string s ser getdata 255 Note that you did not have use ser num before this statement end sub As a result of this automatic switching when an event handler for a serial port event terminates th...

Страница 252: ...ged if you set it somewhere else because a serial port event might have happened since Specifying a port number for a single port platform may seem redundant but it makes your program portable You will have an easier time migrating your program to a multi port platform in the future Serial Settings This topic briefly outlines the range of configurable options available on the serial port this does...

Страница 253: ...n Another property ser autoclose defines whether the port will be closed ser enabled NO once the intercharacter gap reaches ser interchardelay value For the UART mode the intercharacter delay allows your application to process the data more efficiently By keeping the data invisible for a while the serial port can accumulate a large chunk of data that your application will be able to process at onc...

Страница 254: ...600 1200 8 case 1 ser baudrate ser div9600 4 9600 2400 4 case 2 ser baudrate ser div9600 2 9600 4800 2 case 3 ser baudrate ser div9600 8 9600 9600 1 case 4 ser baudrate ser div9600 2 19200 9600 2 case else ser baudrate ser div9600 4 38400 9600 4 end function The serial port can be used in full duplex or half duplex mode as determined by the ser interface property see UART Mode for details In the f...

Страница 255: ...Requesting 7 pages for the RX buffer Will return number of pages which can actually be allocated Allocation requests for buffers of other objects sys buffalloc Performs actual memory allocation as per previous requests Actual memory allocation takes up to 100ms so it is usually done just once on boot for all required buffers If you do not require some buffer you may choose not to allocate any memo...

Страница 256: ...blocking operation This means that on ser send for example the program does not halt and wait until the data is completely sent In fact execution resumes immediately even before the first byte goes out Your program will not freeze just because you ordered it to send a large chunk of data Receiving Data through RX buffer Receiving data is a one step process To extract the data from a buffer use the...

Страница 257: ...er txbuffsize When you want to clear the TX buffer without sending anything use the ser txclear method An example illustrating the difference between ser txlen and ser newtxlen sub on_sys_init dim x y as word declare variables ser rxbuffrq 1 Request one page for the rx buffer ser txbuffrq 5 Request 5 pages for the tx buffer which we will use sys buffalloc Actually allocate the buffers ser setdata ...

Страница 258: ...data_arrival events waiting in the queue The next event is only generated after the previous one has completed processing if and when there is any data available in the RX buffer This means that when handling this event you don t have to get all the data in the RX buffer You can simply handle a chunk of data and once you leave the event handler a new event of the same type will be generated if the...

Страница 259: ...em you need to send out a long string of data when a button is pressed A simple code for this would look like this sub on_button_pressed ser setdata This is a long string waiting to be sent Send me already ser send end sub The code above would work but only if at the moment of code execution the necessary amount of free space was available in the TX buffer otherwise the data would get truncated So...

Страница 260: ...ted data in the TX buffer Handling Buffer Overruns Handling RX buffer overruns The on_ser_overrun event is generated when an RX buffer overrun has occurred It means the data has been arriving to the UART faster than you were handling it and that some data got lost This event is generated just once no matter how much data is lost A new event will be generated only after exiting the handler for the ...

Страница 261: ... committed for sending The ser redir method will only work if the serial port is closed ser enabled 0 NO at the time when this method is executed Therefore it makes sense to check the result of ser enabled execution as in the example below sub on_sys_init if ser redir PL_REDIR_SER PL_REDIR_SER then redirection succeeded else redirection failed perhaps the port is opened end if end sub The performa...

Страница 262: ...urrently selected by the ser num The _on_ser_data_sent event is subordinate to the set notifysent method because this method needs to be called each time you want to receive the _on_ser_data_sent The ser ctsmap ser rtsmap sys buffalloc ser redir and ser mode are subordinate to ser enabled because they can be changed or have effect only when ser enabled 0 NO the sys buffalloc method is not a part o...

Страница 263: ...247 TIDE and Tibbo BASIC User Manual 2000 2008 Tibbo Technology Inc ...

Страница 264: ...ly way to reliably identify the end of one data transmission Baudrate Property Function Sets returns the baudrate divisor value for the selected serial port selection is made through ser num Type Word Value Range 0 65535 default value is platform dependent results in 9600bps See Also UART Mode Serial Settings Details Actual baudrade is calculated as follows 9600 ser div9600 ser baudrate The ser di...

Страница 265: ...e I O line that will act as CTS W0 1in cin input of currently selected serial port selection is made through ser num Type Enum pl_int_num byte Value Range Platform specific see the list of pl_int_num constants in the platform specifications See Also Three modes of the Serial Port Serial Settings Details This property is only available on selected platforms See Platform dependent Programming Inform...

Страница 266: ...If you are dealing with the RS232 port then the states will be in reverse for example 1 PL_SER_SI_HIGHFORINPUT will mean RTS LOW for input HIGH for output Depending on your platform you may be allowed to remap RTS line to other I O pins of the device through the ser rtsmap and ser ctsmap properties Also you may be required to correctly configure RTS line as an input through the io enabled property...

Страница 267: ...ir You also cannot allocate buffer memory for the port do sys buffalloc when the port is enabled Escchar Property Function For selected serial port selection is made through ser num sets retrieves ASCII code of the escape character used for type1 or type2 serial escape sequences Type Byte Value Range 0 255 default 1 SOH character See Also UART Mode Serial Settings Details Which escape sequence is ...

Страница 268: ...time gap of at least 100ms previous data 100ms E C 100ms E C 100ms E C If the time gap before a certain escape character exceeds 100ms then this character is considered to be a part of the escape sequence and is not recorded into the RX buffer If the time gap before a certain escape character is less than 100ms than this character is considered to be a normal data character and is saved into the R...

Страница 269: ...rial Settings Details Only relevant when the ser mode 0 PL_SER_MODE_UART and ser interface 0 PL_SER_SI_FULLDUPLEX full duplex Flow control uses two serial port lines RTS and CTS to regulate the flow of data between the serial port of your device and another attached serial device Depending on your platform you may be allowed to remap RTS and CTS lines to other I O pins of the device through the se...

Страница 270: ...MODE_UART specifies the time that needs to elapse since the arrival of the most recent serial character into the RX buffer to cause the data to be committed and on_ser_data_arrival event generated For Wiegand and clock data mode ser mode 1 PL_SER_MODE_WIEGAND or 2 PL_SER_MODE_CLOCKDATA the time since the most recent data bit high to low transition on the W0 1in cin line is counted In the UART mode...

Страница 271: ...e port is in the UART mode ser mode 0 PL_SER_MODE_UART Depending on your platform you may be allowed to remap RTS and CTS lines to other I O pins of the device through the ser rtsmap and ser ctsmap properties Also you may be required to correctly configure RTS and CTS lines as an input and output through the io enabled property of the io object See Platform dependent Programming Information topic ...

Страница 272: ...e is only possible when the port is closed ser enabled 0 NO Depending on your platform you may be allowed to remap RTS W1out cout and CTS W0 1in cin lines to other I O pins of the device through the ser rtsmap and ser ctsmap properties Also depending on selected mode and your platform you may be required to correctly configure some of your serial port s lines as inputs or outputs through the io en...

Страница 273: ...ed each time after the ser notifysent method is invoked This method together with the on_ser_data_sent event provides a way to handle data sending asynchronously Just like with ser txfree the trigger you set won t take into account any uncommitted data in the TX buffer Num Property Function Sets returns the number of currently selected serial port ports are enumerated from 0 Type Byte Value Range ...

Страница 274: ... a particular port is never generated until the previous one is processed Use ser getdata method to extract the data from the RX buffer You don t have to process all data in the RX buffer at once If you exit the on_ser_data_arrival event handler while there is still some unprocessed data in the RX buffer another on_ser_data_arrival event will be generated immediately This event is not generated fo...

Страница 275: ...ally switched to the port on which this event was generated Whether or not escape sequence detection is enabled and what kind of escape sequence is expected is defined by the ser esctype property Escape sequence detection works even when buffer redirection is set for the serial port using the ser redir method On_ser_overrun Event Function Generated when data overrun has occurred in the RX buffer o...

Страница 276: ... selection is made through ser num redirects the data being RXed to the TX buffer of the same serial port different serial port or another object that supports compatible buffers Syntax ser redir redir as pl_redir as pl_redir Returns Returns 0 PL_REDIR_NONE if redirection failed or the same value as was passed in the redir argument See Also Redirecting Buffers Shorting Part Description redir Platf...

Страница 277: ... of the I O line that will act as RTS W0out cout output of currently selected serial port selection is made through ser num Type Enum pl_io_num byte Value Range Platform specific see the list of pl_io_num constants in the platform specifications See Also Three modes of the Serial Port Serial Settings Details This property is only available on selected platforms See Platform dependent Programming I...

Страница 278: ... 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 because 16 bytes are needed for internal buffer variables Buffer allocation will not work if the serial port to which this buffer belongs is opened ser enabled 1 YES at the time when sys buffalloc executes You can only change buffer sizes of ports that are closed Rxbuffsize R...

Страница 279: ...etails The on_ser_data_arrival event is generated once the RX buffer is not empty i e there is data to process There may be only one on_ser_data_arrival event for each port waiting to be processed in the event queue Another on_serial_data_arrival event for the same port may be generated only after the previous one is handled If during the on_ser_data_arrival event handler execution not all data is...

Страница 280: ...er txlen ser txfree Part Description txdata The data to send Details In the UART mode ser mode 0 PL_SER_MODE_UART the data is added as is For Wiegand and clock data mode ser mode 1 PL_SER_MODE_WIEGAND and ser mode 2 PL_SER_MODE_CLOCKDATA each data character represents one data bit and only bit0 least significant bit of each character is relevant therefore adding 0101 will result in the 0101 sequen...

Страница 281: ...e 256 bytes for the TX buffer of the serial port Syntax ser txbuffrq numpages as byte as byte Returns Actual number of pages that can be allocated byte See Also Allocating Memory for Buffers ser rxbuffrq 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...

Страница 282: ...is the number of buffer pages that was GRANTED through the ser txbuffrq 16 is because 16 bytes are needed for internal buffer variables The serial port cannot TX data when the TX buffer has zero capacity Txclear Method Function For the selected serial port selection is made through ser num clears deletes all data from the TX buffer Syntax ser txclear Returns See Also Buffer Memory Status Details T...

Страница 283: ...al Settings Buffer Memory Status ser newtxlen Details The data in the TX buffer does not become committed until you use the ser send method Your application may use the ser notifysent method to get on_ser_data_sent event once the total number of committed bytes in the TX buffer drops below the level defined by the ser notifysent method Net Object The net object represents the Ethernet interface of...

Страница 284: ...ject is usually initialized once on startup like this sub on_sys_init some other stuff net ip 192 168 1 95 just an example May not work on your network net gatewayip 192 168 1 1 just an example May not work on your network net netmask 255 255 255 0 just an example May not work on your network some other stuff end sub On a lot of networks the IP gateway IP and the netmask parameters of the hosts ar...

Страница 285: ...reflects current link status not the link at the time of event generation Finally there is a on_net_overrun event that is generated when internal RX buffer of NIC overflows 8 3 3 2 Properties Methods Events This section provides an alphabetical list of all properties methods and events of the net object Mac R O Property Function Returns the MAC address of the Ethernet interface Type Dot decimal st...

Страница 286: ...r which sock statesimple 0 PL_SSTS_CLOSED and sock currentinterface 1 PL_INTERFACE_ETHERNET Netmask Property Function Sets returns the netmask of the Ethernet interface of your device Type String Value Range Any valid netmask such as 255 255 255 0 Default 0 0 0 0 See Also net ip net gatewayip Details This property can only be written to when no socket is engaged in communications through the Ether...

Страница 287: ...Linkstate R O Property Function Returns current link status of the Ethernet port of the device Type Enum pl_net_linkstate byte Value Range 0 PL_NET_LINKSTAT_NOLINK No physical Ethernet link exists at the moment the Ethernet port of the device is not connected to a hub 1 PL_NET_LINKSTAT_10BASET The Ethernet port of the device is linked to a hub or directly to another device at 10Mbit sec 2 PL_NET_L...

Страница 288: ...bbo feature a single button called setup button Our modules have a line to connect such a button externally The setup button has a special system function powering up a Tibbo device with this button pressed setup button line held LOW causes the device to enter the serial upgrade mode This mode is for uploading new TiOS firmware file into the device through the serial port The button is not doing a...

Страница 289: ...on on_button_pressed See Also Button pressed Details Multiple on_button_pressed events may be waiting in the event queue You can check the time elapsed since the previous on_button_released event by reading the value of the button time read only property Note that the button object performs debouncing which rejects very brief transitions of the button state This event will not be generated for suc...

Страница 290: ...e Byte Value Range 0 255 See Also Details It only makes sense to read this property inside the on_button_pressed or on_button_released event handlers Once the value of this property reaches 255 127 seconds it stays at 255 there is no roll over to 0 Elapsed time is not counted when the execution of your application is paused Sock Object This is the sockets object It allows you to maintain up to 16 ...

Страница 291: ... represent actual network interfaces such as the net object which represents the Ethernet interface The socket object is responsible for actual IP TCP or UDP communications it doesn t matter which interface these communications are effected through Therefore this is not the right place to look for a property such as IP address This is an attribute of a particular network interface Follows is the l...

Страница 292: ...er which is used to store incoming inband commands messages It is used only when inband commands are enabled The RPL buffer which is used to store outgoing inband replies messages It is used only when inband commands are enabled The VAR buffer which is used to store HTTP request string It is needed only when the socket is in the HTTP mode Socket Selection TiOS supports up to 16 sockets but there m...

Страница 293: ...strate sub on_sys_init This is always the first event executed sock num 0 Supposedly this would make all subsequent properties and methods refer to this socket end sub sub on_sock_data_arrival Then supposing this event executes dim s as string s sock getdata 255 However this event happens on the second socket So now sock num 1 end sub sub on_ser_data_arrival And then this serial port event execute...

Страница 294: ...s ringing Once connection has been established both parties can say something send data at any time and the TCP will make sure that all data sent on one end arrives to the other end TCP connections are expected to be closed terminated properly there is a special exchange of messages between the host to let each other know that connection is being terminated This is called graceful disconnect There...

Страница 295: ...Handling Incoming Connections There is no graceful disconnect for UDP connections The connection can only be discarded our host forgets about it The UDP connection can also timeout Accepting Incoming Connections Master switch for incoming connections It is possible to globally enable or disable acceptance of incoming connections on all sockets irregardless of the setup of individual sockets This i...

Страница 296: ...ou can check which of the socket s local ports is actually engaged in this connection This is done through the sock localport read only property For UDP connections the sock localportlist is all there is For TCP which can be used for plain vanilla data connections or for HTTP you have another property sock httpportlist To be accepted by your socket an incoming TCP connection has to target either o...

Страница 297: ...VM is paused for example has stopped on your breakpoint All communications are handled by the master process so the socket does not need the VM to accept an incoming connection or for that matter receive and send the data Accepting UDP broadcasts UDP datagrams can be sent as broadcasts Broadcast instead of specifying a particular network host as a destination targets a group of hosts on the networ...

Страница 298: ...he new one Reconnects must target the same port and interface Even when the socket has more than one listening port i e sock localportlist 1000 1001 the reconnect will only be accepted if it targets the same local port of the socket as the one already engaged in the current connection being replaced In other words to be successful the reconnect must target the port that is currently returned by th...

Страница 299: ...nnection uses a single port both to send and receive data With UDP this doesn t have to be the case The sock object when it is engaged in a connection can receive the data from one port but send the data to a different port When port switchover is disabled the socket always addresses its outgoing UDP datagrams to the port specified by the sock targetport property When port switchover is enabled th...

Страница 300: ...COL_UDP we are dealing with UDP sock inconmode PL_SOCK_INCONMODE_ANY_IPPORT sock reconmode PL_SOCK_RECONMODE_1 reconnects accepted from any IP port port switchover off sock localportlist 3000 sock targetport 900 Two hosts are sending us datagrams and here is how the socket will react Incoming datagram Socket reaction 192 168 100 40 1000 sends UDP datagram to the port 3000 of our device Datagram ac...

Страница 301: ...ing all further outgoing datagrams to 192 168 100 40 1100 Example PL_SOCK_RECONMODE_3 Setup sock protocol PL_SOCK_PROTOCOL_UDP we are dealing with UDP sock inconmode PL_SOCK_INCONMODE_ANY_IPPORT sock reconmode PL_SOCK_RECONMODE_3 reconnects accepted from any IP port port switchover on sock localportlist 3000 sock targetport 900 Now two hosts are sending us datagrams and here is how the socket will...

Страница 302: ...ut that no socket currently engaged in a connection can accept the packet then the socket object checks all currently idle sockets to see if any of these sockets can accept this packet as a new incoming connection Again all idle sockets are checked starting from socket 0 and up to sock numofsock 1 For TCP a packet that can start such a new connection is a special SYN packet For UDP any incoming da...

Страница 303: ...connections of our own or as is often said performing active opens Establishing an outgoing connection is always an explicit action you use the sock connect method to attempt to do this Once you do this the socket will try to perform an active open to the IP and port specified by the sock targetip and sock targetport properties There is also a sock targetinterface property this one defines which n...

Страница 304: ...xplains how to find out actual connection status at any time see sock state and sock statesimple R O properties Asynchronous nature of the sock object has some interesting implications More On the Socket s Asynchronous Nature topic contains important information on the subject so make sure you read it Sending UDP broadcasts How to send UDP broadcasts UDP datagrams can be sent as broadcasts Broadca...

Страница 305: ...hypothetical sequence of events Incoming outgoing datagram Comment Datagram with contents ABC sent to 192 168 100 40 1000 as soon as sock connect method is invoked We now have the UDP connection with 192 168 100 40 1000 Incoming UDP datagram from 192 168 100 41 20 This will be taken as a reconnect the socket is now engaged in a connection with 192 168 100 41 20 Socket sends out another datagram th...

Страница 306: ...minate the connection There is one intricate detail in the connection termination process that you will have to understand clearly When the VM is not running the socket can accept an incoming connection active open and can accept an active close However the socket won t be able to accept another next incoming connection until the VM has had a chance to run and execute the on_sock_event event handl...

Страница 307: ...tatus topic explains how to find out actual connection status at any time see sock state and sock statesimple read only properties Asynchronous nature of the sock object has some interesting implications More On the Socket s Asynchronous Nature topic contains important information on the subject so make sure you read it Socket re use after connection closing When the socket connection terminates t...

Страница 308: ...P functionality requires that the TCP connection is closed once the HTTP server has finished sending out its response i e HTML page or another file that has been requested In this situation the socket won t need the sock close from your program the connection will be terminated automatically In fact when the socket is in the HTTP mode your sock close sock reset and sock discard will simply be igno...

Страница 309: ...e if newstatesimple PL_SSTS_EST then ser enabled YES connection has been established open port else if ser enabled YES then connection is NOT established Close and clear the port if it is opened ser enabled N0 ser txclear ser rxclear end if end if end sub Sock state and sock statesimple read only properties There is also a pair of read only properties sock state and sock statesimple that allows yo...

Страница 310: ... RX buffer of the socket This is not the same as the next UDP datagram to be extracted from the RX buffer and processed by your application Checking current interface Starting from V1 2 the sock object provides an additional property sock currentinterface not supported by the EM202 200 EV DS202 platform which tells you which network interface the network connection is going through More On the Soc...

Страница 311: ...a connection and follow up on it in the same event handler So how do we do this Here is a simple and WRONG code BAD EXAMPLE Dim s As String sock targetip 192 168 100 40 we prepare for the connection sock targetport 2000 sock connect and now we connect s sock remotemac and now we try to check the MAC WRONG Connection may not be established yet And here is the correct way to handle this For clarity ...

Страница 312: ...this is better One final correction and the code is complete In the Closing Connections topic Socket re use after connection closing section we have already explained that the OS makes sure that the on_sock_event has a chance to execute after the old connection is closed and before the new one is established In the above example both sock close and sock connect are in the same event handler the on...

Страница 313: ...itially boots no memory is allocated to buffers at all Memory for buffers is allocated in pages A page is 256 bytes of memory Allocating memory for a buffer is a two step process first you have to request for a specific allocation a number of pages and then you have to perform the actual allocation For the socket object to be able to send and receive the data you have to give its TX and RX buffers...

Страница 314: ...otocol this is what buffers store a stream of data being sent and received without any separation into individual packets Even for the outgoing data you have no control over how it will be split into packets for transmission over the network Sending Data Sending data a two step process First you put the data in the TX buffer using the sock setdata method and then you perform the actual sending com...

Страница 315: ...P port and broadcast flag indicating whether to send the datagram as a broadcast For the RX buffer headers contain datagram length plus the sender s MAC IP port and broadcast flag indicating whether the datagram is a broadcast Sending Data Just like with TCP sending data through the TX buffer in UDP mode is a two step process first you put the data in the buffer using the sock setdata method and t...

Страница 316: ...s which allow you to monitor it The RX buffer You can check the total capacity of the buffer with the sock rxbuffsize property You can also find out how much data the RX buffer currently contains with the sock rxlen property From these two data you can easily deduce how much free space you have in the RX buffer even though this isn t such a useful datum that s one of the reasons there is no explic...

Страница 317: ...mit sock setdata baz Some more data to send x sock txlen Check total amount of data in the TX buffer y sock newtxlen Check length of data not yet committed end sub Set up a breakpoint HERE Don t step through the code The sending is fast by the time you reach x and y by stepping one line at a time the buffer will be empty and x and y will be 0 Set a breakpoint at the end of the code and then check ...

Страница 318: ...e data in the RX buffer You can simply handle a chunk of data and once you leave the event handler a new event of the same type will be generated Here is a correct example of handling arriving socket data through the on_sock_data_arrival event This example implements a data loopback whatever is received by the socket is immediately sent back out dim rx_tcp_packet_len as word to keep the size of th...

Страница 319: ...ram is discarded Here is an example supposing two datagrams are waiting in the RX buffer and their contents are ABC and 123 The following code will then execute twice sub on_sock_data_arrival dim s as string 2 s sock getdata 255 will get 2 bytes as this is the capacity of s end sub Since s has a maximum capacity of 2 the first time s sock getdata 255 executes you will get AB When the event handler...

Страница 320: ...eed to send out a long string of data when a button is pressed A simple code for this would look like this sub on_button_pressed sock setdata This is a long string waiting to be sent Send me already sock send end sub The code above would work but only if at the moment of code execution the necessary amount of free space was available in the TX buffer otherwise the data would get truncated So obvio...

Страница 321: ...agrams Each time you use the sock send method you draw the boundary between the datagrams the previous one is closed and the new one begins You can even send out an empty UDP datagram by executing sock send without using the sock setdata first Correctly responding to the sender of each UDP datagram With UDP your socket may be receiving UDP datagrams from several different hosts When the on_sock_da...

Страница 322: ...Erase the border between TCP packets and you can t decrypt the data Introduced in Tibbo Basic V2 0 new sock splittcppackets property and on_sock_tcp_packet_arrival event allow you to process incoming TCP data packet by packet To achieve this set the sock splittcppacket 1 YES After that the on_sock_tcp_packet_arrival will be generated for each incoming TCP packet carrying any new data i e not a ret...

Страница 323: ...th the amount of data exceeding MSS Handling Buffer Overruns Handling RX buffer overruns The on_sock_overrun event is generated when an RX buffer overrun has occurred It means the data has been arriving to the RX buffer faster than you were handling it and that some data got lost This event is generated just once no matter how much data is lost A new event will be generated only after exiting the ...

Страница 324: ...m 0 sock redir PL_REDIR_SOCK0 This is a loopback for socket 0 end sub The performance advantage here is enormous due to two factors first you are not handling the data programmatically so the VM isn t involved at all And second the data being received is received directly into the TX buffer from which it is transmitted so there is less copying in memory Of course you cannot do anything at all with...

Страница 325: ...ond method is sometimes better since very often you want to avoid or cannot have another network connection to your device Of course you could just write a BASIC code that would be separating inband commands from the data but this would affect the performance data throughput of your device considerably The sock object natively supports inband commands to avoid this performance penalty In fact inba...

Страница 326: ...character So if you want to send this string Outbound what will actually be sent is Outbound Inband messages are not our invention Many programs such as the HyperTerminal treat the character with code 255 as an escape character Inband related Buffers CMD RPL and TX2 Three buffers are required for inband message processing On startup these buffers are not allocated any memory so you have to do it i...

Страница 327: ...equest will get up to 5 of memory even if you requested for 10 There is a small overhead for each buffer Meaning not 100 of the memory allocated to a buffer is actually available for use 16 bytes of each buffer are reserved for variables needed to administer this buffer such as various pointers etc Thus if we requested and received a buffer with 2 pages 256 2 512 we actually have 496 bytes in whic...

Страница 328: ...method is just like the sock getdata minus the maxinplen argument Total amount of data in the CMD buffer can be checked through the sock cmdlen property Once extracted the data is no longer in the buffer You can use the sock cmdlen property to check how much data is waiting in the CMD buffer There is no dedicated property to tell you the buffer capacity just remember what the sock cmdbuffrq method...

Страница 329: ...nto the CMD buffer in its entirety then the socket will discard the whole command your program won t be notified of this in any way Therefore you are guaranteed to always receive complete inband commands or nothing at all Incomplete inband commads Take a look at this datastream Data comma command2 Moredata What we have here is an inband command that is incomplete a new inband command starts before...

Страница 330: ...ar OK chr sock endchar any more inband commands to process now x instr 1 s chr sock endchar wend end sub And this would be an incorrect way do not split inband replies sock setsendinband chr sock escchar WRONG sock setsendinband OK WRONG sock setsendinband chr sock endchar WRONG For the above example to work well the size of the CMD buffer must not exceed the capacity of string variable s This way...

Страница 331: ...only access first 65534 bytes of each HTML file even if the actual file is larger Make sure that all HTML files in your project are not larger than 65534 bytes This is not to be confused with the size of HTTP output generated by the file A very large output can be generated by a small HTML file due to dynamic data generation and that is OK What s important is that the size of each HTML file in you...

Страница 332: ...ir PL_REDIR_SOCK0 sock num this will allow us to avoid wasting memory on the RX buffer Next f sys buffalloc Performs actual memory allocation as per previous requests Memory allocation takes up to 100ms so it is usually done just once on boot for all required buffers You may not always get the full amount of memory you have requested Memory is not an infinite resource and if you have already reque...

Страница 333: ...tocol must be TCP sock protocol 1 PL_SOCK_PROTOCOL_TCP The socket must be open for incoming connections typically from anybody sock inconmode 3 PL_SOCK_INCONMODE_ANY_IP_ANY_PORT Reconnects should not be enabled this is counter productive for HTTP sock reconmode 0 PL_SOCK_RECONMODE_0 Reconnects are disabled by default so just leave it this way Correct listening HTTP port must be set Default HTTP po...

Страница 334: ...n connection is made to port 23 the socket will work as a regular data socket as was described in previous sections When connection is made to port 80 the socket will automatically switch into the HTTP mode There is a property sock httpmode that tells you which mode the socket is in regular data mode or HTTP You can even forcefully switch any TCP connection into the HTTP mode by setting sock httpm...

Страница 335: ...tain request variables These are stored into the VAR buffer from which your program can read them out later No on_sock_data_arrival event is generated when the HTTP request string is received into the RX buffer Once entire request has been received the socket prepares and starts to output the reply Your program has no control over this output until a BASIC code fragment is encountered in the HTTP ...

Страница 336: ...HTML Notice how we did not have to use sock num it is set automatically when control is passed to BASIC Be careful not to get your data truncated The above example is seemingly correct and in this particular case will work fine because there is not much static data preceding the point where we generate dynamic content and not much dynamic content is generated as well Generally speaking you cannot ...

Страница 337: ...t comes to processing dynamic part of the files one of the requests will be first It is also entirely possible that when executing the BASIC procedure from the first instance of the file execution arrives at doevents and the second instance of the same file will start to process After all doevents allows other events to execute so this can include activity in other sockets Now if the same BASIC pr...

Страница 338: ...b server looks at defined substitutions If the requested file is not on the list the web server returns the 404 error If the file is on the list of defined substitutions the browser looks for the file with the same name but html extension pix html If there is no such file the 404 error is again the answer If this HTML file exists the server outputs this file but makes it look like it was a file of...

Страница 339: ...his her name and password on page index html Actual login is processed on page login html The data is passed between these two pages invisibly using the HTTP POST method Here is the file index html html body form action form_get html method post enctype multipart form data username Input Type text name user br password Input Type password name pwd br Input Type submit value send form body html And...

Страница 340: ...uation described in the previous topic use a more complex but very reliable way of handling large HTTP variable data The on_sock_postdata event is generated when there is data in the VAR buffer In this regard the event is similar in nature to the on_sock_data_arrival event which is generated when the RX buffer of the socket has data Unlike the on_sock_data_arrival event the on_sock_postdata will f...

Страница 341: ...255 very simplified but illustrates the point End Sub Then in the HTML file It is necessary to remember that a portion of the HTTP variable data may still be unhandled by the time you get here html body While sock httprqstring extract the remaining part of the variable data fd setdata sock gethttprqstring 255 Wend body html It is unlikely that user login will require such careful handling User nam...

Страница 342: ...a Data format in the VAR buffer depends on the method used VAR buffer contents HTTP GET method Supposing the client has sent the following request GET form_get html user CHUCKY pwd THEEVILDOLL HTTP 1 1 Host 127 0 0 1 1000 User Agent Mozilla 5 0 and so on The VAR buffer will get everything past the URL and until the first CR LF The part is highlighted in blue There are two variables user and pwd Th...

Страница 343: ...the list of network interfaces on which this socket will accept incoming connections Type String Value Range Platform specific See the list of supported interfaces in the Platform dependent Programming Information topic found inside the documentation for your platform See Also Accepting Incoming Connections Details Each network interface has a name For example the Ethernet interface goes by the na...

Страница 344: ...rn the broadcast status of the most recent datagram received by the socket Close Method Function For the selected socket selection is made through sock num causes the socket to close the connection with the other host Syntax sock close Returns See Also Details For established TCP connections this will be a graceful disconnect if the TCP connection was in the connection opening or connection closin...

Страница 345: ...r has 0 capacity Unlike for TX or RX buffers there is no property to read out actual CMD buffer capacity in bytes This capacity can be calculated as num_pages 256 16 or 0 when num_pages 0 where num_pages is the number of buffer pages that was GRANTED through the sock cmdbuffrq method 16 is because 16 bytes are needed for internal buffer variables Buffer allocation will not work if the socket port ...

Страница 346: ...orted by the EM202 200 EV DS202 platform Method invocation will have effect only if connection was closed at the time when the method was called sock state in one of PL_SST_CLOSED states Connectiontout Property Function For the currently selected socket selection is made through sock num sets returns connection timeout threshold for the socket in half second increments Type Word Value Range 0 6553...

Страница 347: ...S202 platform Discard Method Function For the selected socket selection is made through sock num causes the socket to discard the connection with the other host Syntax sock discard Returns See Also sock close sock reset Details Discarding the connection means simply forgetting about it without notifying the other side of the connection in any way This method will be ignored when called from within...

Страница 348: ...e sock escchar property and OC is any character other than EC With inband commands enabled data characters with code matching that of the escape character is transmitted as EC EC that is two identical characters are needed to transmit a single data character with code matching that of escape character This property is irrelevant when inband commands are disabled sock inbandcommands 0 NO The progra...

Страница 349: ...P the length of data that will be extracted is limited to the UDP datagram being processed Additional conditions apply to UDP datagram processing see on_sock_data_arrival event and sock nextpacket method Gethttprqstring Method Function For the selected socket selection is made through sock num extracts up to 255 bytes of the HTTP request string from theVAR buffer Syntax ser gethttprqstring maxinpl...

Страница 350: ... the receiving buffer variable Several inband commands may be waiting in the CMD buffer Each command will always be complete i e there will be no situation when you will extract a portion of the command because the end of this command hasn t arrived yet Inband commands stored in the CMD buffer will have escape character see sock escchar property and the character after the escape character already...

Страница 351: ...y Function For the currently selected socket selection is made through sock num sets returns whether TCP HTTP connection will be kept opened after the HTTP request has been processed and the HTML page has been sent out Type Enum no_yes byte Value Range 0 NO default connection will be closed standard HTML server behavior 1 YES will be kept opened special string will be used as a separator See Also ...

Страница 352: ...ck num returns up to 255 bytes of the HTTP request string stored in the VAR buffer Type String Value Range Default See Also Sock varbuffrq Details The sock httprqstring is a property it can be invoked several times and will return the same data when this property is used the data is not deleted from the VAR buffer VAR buffer contents are explained in Details on Variable Data This property is only ...

Страница 353: ...uffer shorting is enabled for the socket see the sock redir method The program won t be able to change the value of this property when the socket is not idle sock statesimple 0 PL_SSTS_CLOSED Inconenabledmaster Property Function A master switch that globally disables incoming connection acceptance on all sockets irregardless of each socket s individual setup Type Enum no_yes byte Value Range 0 NO ...

Страница 354: ...IP matching sock targetip but any port 3 PL_SOCK_INCONMODE_ANY_IP_ANY_PORT The socket will accept an incoming connection from any IP and any port See Also sock reconmode sock localportlist sock httpportlist Details Localport R O Property Function For the currently selected socket selection is made through sock num returns current local port of the socket Type Word Value Range 0 65535 default 0 See...

Страница 355: ...incoming connection This property is of string type and the list of ports is a comma separated string i e 1001 3000 to accept connections on either port 1001 or 3000 Max string length for this property is 32 bytes Notice that there is also a sock httpportlist property that defines a list of listening ports for HTTP TCP connections Newtxlen R O Property Function For the selected socket selection is...

Страница 356: ...ming UDP packets at once and within a single event handler Notifysent Method Function Using this method for the selected socket selection is made through sock num will cause the on_sock_data_sent event to be generated when the amount of committed data in the TX buffer is found to be below threshold number of bytes Syntax notifysent threshold as word Returns See Also Part Description threshold Amou...

Страница 357: ...e Value Range platform dependent See Also sock num Details Outport Property Function For the currently selected socket selection is made through sock num sets returns the number of the port that will be used by the socket to establish outgoing connections Type Word Value Range 0 65535 default 0 See Also Details If this property is set to 0 then the socket will use automatic port numbers for the fi...

Страница 358: ...e is still some unprocessed data in the RX buffer another on_sock_data_arrival event will be generated immediately For UDP protocol sock protocol 0 PL_SOCK_PROTOCOL_UDP the RX buffer preserves datagram boundaries Each time you enter the on_sock_data_arrival event handler you get to process next UDP datagram If you do not process entire datagram contents the unread portion of the datagram is discar...

Страница 359: ...es the same set of constants as the sock state The newstatesimple argument uses the same set of constants as the sock statesimple See sock state and 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 and sock eventsimple R O properties which are no ...

Страница 360: ...of such data can exceed the VAR buffer capacity If this is not handled properly the HTTP request execution may stall indefinitely see Working with HTTP Variables After the socket accepts an HTTP connection this event is not generated for this particular connection until the VAR buffer becomes full Once this happened the event is generated even if there is a single byte waiting to be processed in t...

Страница 361: ...ket Protocol Property Function For the currently selected socket selection is made through sock num selects the transport protocol Type Enum pl_sock_protocol byte Value Range 0 PL_SOCK_PROTOCOL_UDP default UDP transport protocol 1 PL_SOCK_PROTOCOL_TCP TCP transport protocol See Also Details Notice that there is no HTTP selection as HTTP is not a transport protocol TCP is the transport protocol req...

Страница 362: ...ll happen TCP reconnects accepted from any IP any port See Also Details Reconnect situation is when a passive open and resulting connection replace for the same socket the connection that was already in progress For UDP this property additionally defines whether a port switchover will occur as a result of an incoming connection passive open or a reconnect Port switchover is when the socket starts ...

Страница 363: ... will actually return the data for the TX buffer to which this RX buffer was redirected sock rxbuffsize will actually be returning the size of the TX buffer sock rxclear method will actually be clearing the TX buffer sock rxlen method will be showing the amount of data in the TX buffer Remoteip R O Property Function For the currently selected socket selection is made through sock num returns the I...

Страница 364: ... the currently selected socket selection is made through sock num returns the port number of the host with which this socket had the most recent or currently has a connection Type Word Value Range 0 65535 default 0 See Also sock remotemac sock remoteip sock bcast Details The application cannot directly change this property it can only specify the target port for active opens through the sock targe...

Страница 365: ...buffer of the socket Syntax sock cmdbuffrq numpages as byte as byte Returns Actual number of pages that can be allocated Byte See Also sock cmdbuffrq Part Description numpages Requested numbers of buffer pages to allocate Details The RPL buffer is the the buffer that stores outgoing inband replies messages Actual allocation happens when the sys buffalloc method is used The socket is unable to send...

Страница 366: ...Property Function For the selected socket selection is made through sock num returns the length of data in bytes waiting to be send out from the RPL buffer Type Word Value Range See Also sock cmdlen sock rplfree sock inbandcommands Details Your application adds inband replies to the RPL buffer with the sock setsendinband method Several inband replies may be waiting in the RPL buffer Rxbuffrq Metho...

Страница 367: ...e 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 Rxbuffsize R O Property Function For the currently selected socket selection is made through sock num returns current RX buffer capacity in bytes Type Word Value Range 0 65535 See Also Details Buffer capacity can be changed through the sock rxbuffrq The so...

Страница 368: ...e sock nextpacket method Rxlen R O Property Function For the selected socket selection is made through sock num returns total number of bytes currently waiting in the RX buffer to be extracted and processed by your application Type Word Value Range 0 65535 default 0 See Also Details The on_sock_data_arrival event is generated once the RX buffer is not empty i e there is data to process There may b...

Страница 369: ...selected socket selection is made through sock num adds the data passed in the txdata argument to the contents of the TX buffer Syntax ser setdata byref txdata as string Returns See Also Part Description txdata The data to send this data will be added to the contents of the TX buffer Details If the buffer doesn t have enough space to accommodate the data being added then this data will be truncate...

Страница 370: ...y When adding the data to the RPL buffer make sure you are adding entire inband message at once you are not allowed to do this in portions Sinkdata Property Function For the currently selected socket selection is made through sock num specifies whether the incoming data should be discarded Type Enum yes_no byte Value Range 0 NO default normal data processing 1 YES discard incoming data See Also Si...

Страница 371: ...n 0 your program can make sure that the packet sent will have exactly the size you needed The property is only relevant when the sock inbandcommands 0 NO With inband commands enabled the socket will always behave as if the sock splittcppackets 0 NO The program won t be able to change the value of this property when the socket is not idle sock statesimple 0 PL_SSTS_CLOSED Notice that sending out TC...

Страница 372: ...356 Platforms 2000 2008 Tibbo Technology Inc Type Enum pl_sock_state byte ...

Страница 373: ..._CMD Connection is closed it was an active reset issued by the application Applies only to TCP 10 PL_SST_CL_ARESET_RE_PO Connection is closed it was an active reset issued because of excessive retransmission attempts during a passive open Applies only to TCP 11 PL_SST_CL_ARESET_RE_AO Connection is closed it was an active reset issued because of excessive retransmission attempts during an active op...

Страница 374: ...S_ARP ARP resolution is an progress it is an active open Applies both to UDP and TCP 2 PL_SSTS_PO Connection is being established it is a passive open Applies only to TCP 3 PL_SSTS_AO Connection is being established it is an active open Applies only to TCP 4 PL_SSTS_EST Connection is established Applies both to UDP and TCP 5 PL_SSTS_PC Connection is being closed it is a passive close Applies only ...

Страница 375: ...chover even if the latter is enabled through the sock reconmode property Targetinterface Property Function For the currently selected socket selection is made through sock num selects the network interface through which an outgoing network connection will be established Type Enum pl_sock_interfaces byte Value Range Platform specific See the list of pl_sock_interfaces constants in the platform spec...

Страница 376: ...t port to which the socket will attempt to connect to For passive opens specifies in certain cases the only port from which an incoming connection will be accepted Type Word Value Range 0 65535 default 0 See Also sock targetip sock remoteip Details For active opens this property is only relevant at the moment of connection establishment For incoming connections whether this property will matter or...

Страница 377: ...56 bytes for the TX2 buffer of the socket Syntax sock tx2buffrq numpages as byte as byte Returns Actual number of pages that can be allocated Byte See Also sock txbuffrq Part Description numpages Requested numbers of buffer pages to allocate Details The TX2 buffer is required when inband commands are enabled sock inbandcommands 1 YES without it the socket won t be able to TX data Returns actual nu...

Страница 378: ...rq numpages as byte as byte Returns Actual number of pages that can be allocated Byte See Also sock tx2buffrq Part Description numpages Requested numbers of buffer pages to allocate Details Actual allocation happens when the sys buffalloc method is used The socket is unable to TX data if its TX buffer has 0 capacity Actual current buffer capacity can be checked through the sock txbuffsize which re...

Страница 379: ...ages 256 16 or 0 when num_pages 0 where num_pages is the number of buffer pages that was GRANTED through the sock txbuffrq 16 is because 16 bytes are needed for internal buffer variables The socket cannot TX data when the TX buffer has zero capacity Txclear Method Function For the selected socket selection is made through sock num clears deletes all data from the TX buffer Syntax sock rxclear Retu...

Страница 380: ... data in the TX buffer does not become committed until you use the sock send method Your application may use the sock notifysent method to get on_sock_data_sent event once the total number of committed bytes in the TX buffer drops below the level defined by the sock notifysent method Urlsubstitutes Function A comma separated list of filenames whose extensions will be automatically substituted for ...

Страница 381: ...oc method is used Unlike for TX or RX buffers there is no property to read out actual VAR buffer capacity in bytes This capacity can be calculated as num_pages 256 16 or 0 when num_pages 0 where num_pages is the number of buffer pages that was GRANTED through the sock varbuffrq 16 is because 16 bytes are needed for internal buffer variables Buffer allocation will not work if the socket port to whi...

Страница 382: ...any devices a number of I O lines may be shared with inputs outputs of special function blocks serial ports etc When a special function block is enabled I O lines it uses cannot should not be manipulated though the io object Line Port Manipulation With Pre selection I O line manipulation with pre selection works like this you first select the line you want to work with using the io num property Yo...

Страница 383: ...on is good when you need to deal with several I O lines at once For this use io lineset io lineget and io invert methods These methods require the line number to be supplied directly as a parameter Therefore pre selection with the io num property is not necessary Moreover executing these methods leaves the io num value intact Here is an example of a serialized clock data output The clock line is P...

Страница 384: ...put While io state HIGH wait until the line is pulled LOW externally Wend On devices with explicit output buffer control you need to define whether the line is an output set io enabled 1 YES or input set io enabled 0 NO Trying to read the line while it is in the output mode will simply return the state of the line s own output driver Forcing the line externally while it works as an output may caus...

Страница 385: ...en the state change from LOW to HIGH or from HIGH to LOW has been detected on the related interrupt line Event handler for the on_io_int event can then determine what triggered the interrupt Sub On_io_int linestate As Byte check if it is the interrupt line 0 that has caused the interrupt If linestate And h01 0 Then yes interrupt has been triggered by the interrupt line 0 End If End Sub Please note...

Страница 386: ...of the output buffer for the currently selected I O line selection is made through the io num property Type Enum no_yes byte Value Range 0 NO default disabled I O line works as an input 1 YES enabled I O line works as an output See Also Controlling Output Buffers io state Details Depending on the platform explicit configuration of the output buffers may or may not be required See Platform dependen...

Страница 387: ...t see Controlling Output Buffers for details Invert Method Function Inverts the state of the I O line specified by the num argument Syntax io invert num as pl_io_num Returns See Also Line Port Manipulation Without Pre selection io lineget io lineset Part Description num Platform specific See the list of pl_io_num constants in the platform specifications Details No line pre selection with the io nu...

Страница 388: ...Platform specific See the list of pl_io_num constants in the platform specifications state LOW or HIGH low_high enum values Details No line pre selection with the io num property is required and the value of the io num will not be changed Num Property Function Sets returns the number of currently selected I O line Type Enum pl_io_num byte Value Range Platform specific See the list of pl_io_num con...

Страница 389: ... through the io portnum property Type Byte Value Range Default 0 all eight I O lines of the port are configured as inputs See Also Controlling Output Buffers io portstate Details Each I O port groups eight I O lines Each bit of this property s byte value corresponds to one member I O line Setting the bit to 0 keeps the output buffer turned off while setting the bit to 1 enables the output buffer D...

Страница 390: ...ipulation With Pre selection Details Selects a particular I O port to be manipulated through the io portstate and io portenabled properties the latter may or not be available on your platform Each port groups eight I O lines The list of available I O ports is defined by the pl_io_port_num constant Portset Method Function Sets the I O port specified by the num argument to the state specified by the...

Страница 391: ...tate of the currently selected I O line selection is made through the io num property Type Enum low_high byte Value Range 0 LOW 1 HIGH Default value is hardware dependent See Also Line Port Manipulation with Pre selection io enabled Details Romfile Object The romfile object allows you to access resource files that you have added to your project Resource files appear in the Resource Files folder of...

Страница 392: ...a variable of word type therefore you can only access up to 65534 bytes in each file You can add larger files to the project but only first 65534 bytes of each file will be accessible from your application The romfile find method is used to find desired substring in the resource file This allows you to organize quick search for the file portion you need which is very useful if you keep some table ...

Страница 393: ...es you will need to open the file not for the purpose of accessing it but for the purpose of passing a reference to this file to another object Such reference pointer is provided by the romfile offset read only property 8 3 7 1 Find Method Function Locates Nth instance of a substring within a currently opened resource ROM file Syntax romfile find frompos as word byref substr as string num as word ...

Страница 394: ... actual number of bytes that was read out The romfile object can only access first 65534 bytes of each file This is because the romfile pointer is a variable of word type This method will also work only within this limit 8 3 7 3 Offset R O Property Function Returns the offset of the currently opened file Type Dword Value Range Only limited by the size of compiled binary of your project See Also ro...

Страница 395: ... pointer position in the resource ROM file Type Word Value Range See explanation below See Also Romfile Object Details When the file is re opened with the romfile open method the pointer is reset to the first character of the file position 1 except when the file is not found or contains no data in which case the pointer will permanently be equal to 0 Pointer position cannot exceed file size see th...

Страница 396: ...tor get method is used to read the data from the EEPROM Here is a simple example how to save the IP address of your device in the EEPROM dim s as string dim x as byte s ddval net ip this way it will take less space in the EEPROM only 4 bytes needed x stor set s 0 write EEPROM check result if x len s then EEPROM write failure do something about this end if And here is how you read this data back fr...

Страница 397: ...nfiguration area 1 See Also Stor Object stor size Details By default the value returned by this property is the address of the first EEPROM location just above the special configuration area for details see Platform dependent Programming Information topic inside your platform specifications section For example if the size of the special configuration area on your platform is 8 bytes then stor base...

Страница 398: ...e address just above the special configuration area of your device for details on what this area actually stores see Platform dependent 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 peri...

Страница 399: ... from set to setdata This is because the period separating stor from setdata is now a true part of the language i e it is recognized as a syntax unit not just part of identifier Hence Tibbo Basic sees stor and set as separate entities and set is a reserved word that can t be used 8 3 8 4 Size R O Property Function Returns total EEPROM memory capacity in bytes for the current device Type Word Value...

Страница 400: ...hod If the pattern is looped it will continue playing until you change it If the pattern is not looped it will play once and then the on_pat event will be generated When the event handler is entered the pat channel property will be automatically set to the channel number for which the event was generated LED patterns offer a convenient way to tell the user what your system is doing You can devise ...

Страница 401: ...h the pat channel property sets returns the number of the I O line that will act as a green LED control line Type Enum pl_int_num byte Value Range Platform specific see the list of pl_int_num constants in the platform specifications Default values Channel 0 1 no mapping read only the green status LED control line of Tibbo device is always used by this channel Channels 1 4 PL_IO_NULL non existent l...

Страница 402: ... selected LED channel selection is made through the pat channel property Syntax pat play byref pattern as string patint as pl_pat_int Returns See Also Part Description pattern Pattern string can include the following characters both LEDs off R or r red LED on G or g green LED on B or b both LEDs on looped pattern can reside anywhere in the pattern string double speed pattern can reside anywhere in...

Страница 403: ... 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 Remap as needed and don t forget to configure the selected I O line as an output this won t happen automatically Beep O...

Страница 404: ... a permanent non stop square wave on CO pin load the following pattern beep play B PL_PAT_CANINT 8 3 10 1 Divider Property Function Sets the frequency of the square wave output on the CO line Type Word Value Range 0 65535 default 1 divide by 2 See Also Details Actual frequency can be calculated as base_frq 2 beep divider Setting this property to 0 is equivalent to 65536 i e actual frequency will b...

Страница 405: ...interrupt another pattern that is already playing 0 PL_BEEP_NOINT cannot interrupt 1 PL_BEEP_CANINT can interrupt Details Maximum pattern length is 16 steps The on_pat event is generated once the pattern finishes playing looped patterns never finish playing RTC Object The RTC object facilitates access to the real time counter RTC of the device The RTC is an independent hardware counter that has it...

Страница 406: ...ead only property that tells you whether the RTC is working Notice that after the device powers up and provided that the backup power was not present at all times the RTC may be in the undetermined state and not work properly until the rtc set method is executed at least once Incorrect behavior may include failure to increment or incrementing at an abnormal rate Rtc running cannot be used to relia...

Страница 407: ...se the period separating rtc from getdata is now a true part of the language i e it is recognized as a syntax unit not just part of identifier Hence Tibbo Basic sees rtc and get as separate entities and get is a reserved word that can t be used 8 3 11 2 Running R O Property Function Returns current RTC state Type Enum no_yes byte Value Range 0 NO RTC is not running 1 YES RTC is running See Also RT...

Страница 408: ...ning cannot be used to reliably check RTC state in this situation 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 is now a true part of the language i e it is recognized as a syntax unit not just part of ident...

Страница 409: ... lcd object is ready to work with a wide range of displays some of which are not actually of LCD type So the proper name for this object should be display object Nevertheless we have decided to keep this name typing lcd is faster and the name has been in use for a while A number of R O properties inform your application about the type and other vital parameters of the currently selected display Lc...

Страница 410: ...rs number of bits per pixel for this color channel high byte and the bit position of the field in the color word low byte Supposing lcd redbits h0500 lcd bluebits h0605 and lcd greenbits h050B You reconstruct the composition of the red green and blue bits in a word In this example the red field is the first one on the right followed by the blue field this field starts from bit 5 then green field s...

Страница 411: ...ing Information of your platform documentation to determine if this step is required Set the resolution of the display lcd width lcd height These values depend on the panel not the controller so they cannot be detected automatically Your application needs to set them manually Set lcd rotated 1 YES if you wish the display image to be rotated 180 degrees that is the display of your device is install...

Страница 412: ...le lcd forecolor hFFFF lcd backcolor 0 The following methods are provided to output data onto the screen and they all use the lcd forecolor and where necessary the lcd backcolor Lcd line lcd verline lcd horline the line is drawn using the forecolor Lcd rectangle the border is drawn using the forecolor the internal area of the rectangle is not filled Lcd filledrectangle the border is drawn using th...

Страница 413: ... an unfilled rectangle using lcd forecolor as pen color and pen width defined by the lcd linewidth property Lcd filledrectangle will additionally paint the internal area using lcd backcolor Example and its result lcd forecolor color_blue we assume we have already set color_blue lcd backcolor color_green we assume we have already set color_green lcd rectangle 0 0 20 20 width 1 default lcd linewidth...

Страница 414: ... 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 Non aligned text Once the font has been selected you can start printing You do this with the lcd print method This method always produces a single line output Two properties lcd texto...

Страница 415: ...gular area Four properties lcd textorientation lcd textalignment lcd texthorizontalspacing and lcd textverticalspacing define how your text will be printed To fit within the target area the lcd object will split the text into several lines as necessary Only the text that can fit within the area will be displayed You can add your own line breaks by using the character ASCII code 96 Example lcd text...

Страница 416: ...s are included into the font file and allows to conduct very efficient character search within the file Support for proportional fonts Hence each character s width is individually defined Support for fonts with anti aliasing Anti aliasing is achieved by adjusting the intensity brightness of individual pixels In an anti aliased font each pixel of character bitmap is represented by 2 or more bits of...

Страница 417: ...lowing information Off set By tes Data Comment 0 2 Num_o f_chars Total number of characters in this font file 2 1 Pixels_ per_byt e 0 eight pixels byte 1 bit pixel no anti aliasing 1 four pixels byte 2 two pixels byte 3 one pixel byte Modes 1 2 and 3 are currently not supported these modes are for anti aliasing and will be supported in the future 3 1 Orienta tion 0 pixels are grouped vertically 1 ...

Страница 418: ...s explained in the next section Bitmap offset table This table has the same number of entries as the total number of characters included in the font file Each entry consists of one field a 32 bit offset of a particular bitmap with respect to the beginning of the font file Now you can see how we were able to calculate the data for the bitmap_addr_offset field of the code groups table The header of ...

Страница 419: ...n the second row are unused Bitmap C takes 28 bytes The first byte encodes 8 horizontally arranged pixels at the top left corner of the bitmap Subsequent bytes represent all other pixel groups and the order is top to bottom left to right There are 2 columns of bytes and bits 2 7 of each byte in the second column are unused Searching for a character bitmap Here is how a target character bitmap is f...

Страница 420: ... unused Displaying Images Lcd bmp outputs a full image or a portion of the image from a BMP file Naturally this file must be present in your project see how to add a file Here is a simple example of how to display an image romfile open mad_happiness bmp lcd bmp romfile offset 0 0 0 0 65535 65535 see how we set maxwidth and maxheight to 65535 max value This way we specify that the entire image shou...

Страница 421: ...rformance Nobody likes sluggish products and the way you work with your display can greatly influence perceived performance of your product We say perceived because very often this has nothing to do with the actual speed at which your device completes required operations Group display related operations together The most important aspect of your application s performance related to the display is ...

Страница 422: ...our items at once Use display locking No matter how hard you try to group all display related output together executing lcd object s methods one after another may still take considerable time Perceived performance can be improved on displays that allow you to lock display picture change display data then unlock the display again With this approach the user will see all changes appear instantly Not...

Страница 423: ...1 And you know what The display won t be unlocked because with the lcd object it is possible to nest locks unlocks In the following example we do three consecutive locks and the display is locked right on the first one We then do three consecutive unlocks and the display is not unlocked until after the third one is executed lcd lock lcd lockcount 1 display is now locked lcd lock lcd lockcount 2 lc...

Страница 424: ...ock unlock is performed Test hardware TEV LB0 test board This board is a part of the EM1000 TEV development system See Programmable Hardware Manual for details I O mapping for WG12864F This panel requires 6 I O lines and an 8 bit data bus Control lines are RST EN CS1 CS2 D I and R W Each control line can be connected to any I O pin of your device and each such I O pin must be configured as an outp...

Страница 425: ...43 42 4 RST EN CS1 CS2 D I R W DATA7 0 configure control lines as outputs io num PL_IO_NUM_46 EN io enabled YES io num PL_IO_NUM_44 RST io enabled YES io num PL_IO_NUM_40 CS1 io enabled YES io num PL_IO_NUM_41 CS2 io enabled YES io num PL_IO_NUM_42 R W io enabled YES io num PL_IO_NUM_43 D I io enabled YES set resolution lcd width 128 lcd height 64 optionally set lcd rotated here lcd enabled YES do...

Страница 426: ...it data bus Control lines are RES D C R W E and CS Each control line can be connected to any I O pin of your device and each such I O pin must be configured as an output if your device requires explicit I O line buffer configuration The data bus can be connected to any 8 bit port DO NOT configure this port for output The controller also has BS1 and BS2 interface type selection pin For proper opera...

Страница 427: ... the horizontal lines of the panel usually the top or bottom line to display random garbage while the display is locked We have some ideas for workaround contact us if you encounter this problem Test hardware TEV LB2 test board This board is a part of the EM1000 TEV development system See Programmable Hardware Manual for details I O mapping for AM176220 The panel requires 5 I O lines and a 17 bit ...

Страница 428: ...ing is done using the TEV LB2 board lcd iomapping 44 43 42 41 40 4 RESET RS WR RD CS DB7 0 io num PL_IO_NUM_44 RESET io enabled YES io num PL_IO_NUM_43 RS io enabled YES io num PL_IO_NUM_42 WR io enabled YES io num PL_IO_NUM_41 RD io enabled YES io num PL_IO_NUM_40 CS io enabled YES set resolution lcd width 176 lcd height 220 optionally set lcd rotated here lcd enabled YES done turn on the backlig...

Страница 429: ...erline Method lcd rectangle Method lcd filledrectangle Method lcd fill Method lcd setfont Method lcd fontheight R O Property lcd fontpixelpacking R O Property lcd textalignment Property lcd textorientation Property lcd texthorizontalspacing Property lcd textverticalspacing Property lcd print Method lcd printaligned Method lcd getprintwidth Method lcd bmp Method Miscellaneous lcd error R O Property...

Страница 430: ... lcd bluebits properties to see how the fields are combined into the color word Bitsperpixel R O Property Function Returns the number of bits available for each pixel of the currently selected controller panel Type Byte Value Range Value depends on the currently selected controller panel See Also Understanding Controller Properties Working With Pixels and Colors Details Controller panel selection ...

Страница 431: ...d For example if the high byte is equal to 6 then there are 64 levels for blue This property also tells you the bit position and length of the blue field in color 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 15 gggggbbb...

Страница 432: ...ny other type of BMP file Compressed BMP files will be rejected too The method takes into account the type of the currently selected controller panel selection is made through the Customize Platform dialog accessible through the Project Settings dialog It will check the values of lcd paneltype lcd bitsperpixel lcd redbits lcd greenbits and lcd bluebits and produce the best output possible for the ...

Страница 433: ...of the controller panel that is expected to be connected If the display is not properly connected or the lcd object is not set up property to work with this display the lcd error will be set to 1 YES on attempt to enable the display set lcd enabled 1 YES Fill Method Function Paints the area with the pen color lcd forecolor Syntax lcd fill x as word y as word width as word height as word Returns Se...

Страница 434: ...th 1 y2 Y coordinate of the second point Value range is 0 to lcd height 1 Details The border is drawn with the specified line width lcd linewidth and pen color lcd forecolor The rectangle is then filled using the background color lcd backcolor Setting the lcd linewidth to 0 will create a rectangle with no border basically a filled area The display panel must be enabled lcd enabled 1 YES for this m...

Страница 435: ...olor Property Function Specifies current pen drawing color Type Word Value Range 0 65535 Default 65535 hFFFF See Also Understanding Controller Properties Working With Pixels and Colors lcd backcolor lcd linewidth Details Pen color is used when drawing lines lcd line lcd verline lcd horline and rectangles lcd rectangle lcd filledrectangle as well as displaying text lcd print lcd printaligned Proper...

Страница 436: ...er of green bits per pixel high byte and the position of the least significant green bit within the color word low byte Type Word Value Range Value depends on the currently selected controller panel See Also Understanding Controller Properties Working With Pixels and Colors Details The value of this property depends on the currently selected controller panel S election is made through the Customiz...

Страница 437: ...d This property can only be changed when the lcd is disabled lcd enabled 0 NO Horline Method Function Draws a horizontal line Syntax lcd horline x1 as word x2 as word y as word Returns See Also Lines Rectangles and Fills lcd rectangle lcd filledrectangle lcd fill Par t Description x1 X coordinate of the first point Value range is 0 to lcd width 1 x2 X coordinate of the second point Value range is ...

Страница 438: ...ty Function Defines the list of I O lines to interface with the currently selected controller panel Type String Value Range Value depends on the currently selected controller panel Default See Also Preparing the Display for Operation Details Controller panel selection is made through the Customize Platform dialog accessible through the Project Settings dialog Different controllers panels require a...

Страница 439: ...or Drawing horizontal lcd horline or vertical lcd verline lines is more efficient than drawing generic lines and should be used whenever possible The display panel must be enabled lcd enabled 1 YES for this method to work Linewidth Property Function Specifies current pen width in pixels Type Byte Value Range 1 255 Default 1 1 pixel See Also Lines Rectangles and Fills lcd forecolor lcd backcolor De...

Страница 440: ...l of the display lock Type Byte Value Range 0 255 Default 0 display unlocked See Also Details Invoking lcd lock increases the value of this property by 1 If 255 is reached the value does not roll over to 0 and stays at 255 Invoking lcd unlock decreases the value of this property by 1 When 0 is reached the value does not roll over to 255 and stays at 0 The display is locked when lcd lockcount is no...

Страница 441: ...ller memory for the currently selected controller panel Type Enum ver_hor byte Value Range 0 PL_VERTICAL Several vertically adjacent pixels are packed into each byte of controller memory 1 PL_HORIZONTAL Several horizontally adjacent pixels are packed into each byte of controller memory See Also Understanding Controller Properties Details Controller panel selection is made through the Customize Pla...

Страница 442: ...ligned if you want to print several lines of text at once The display panel must be enabled lcd enabled 1 YES for this method to work Printaligned Method Function Print texts on several lines if necessary within a specified rectangular area Syntax lcd printaligned byref str as string x as word y as word width as word height as word as byte Returns Total number of text lines produced See Also Worki...

Страница 443: ...Lines Rectangles and Fills lcd line lcd verline lcd horline lcd filledrectangle lcd fill Par t Description x1 X coordinate of the first point Value range is 0 to lcd width 1 y1 Y coordinate of the first point Value range is 0 to lcd height 1 x2 X coordinate of the second point Value range is 0 to lcd width 1 y2 Y coordinate of the second point Value range is 0 to lcd height 1 Details The rectangle...

Страница 444: ...struct the composition of the red green and blue bits in a word bit 15 gggggbbbbbbrrrrr bit 0 In this example the red field is the first field and occupies 5 bits 4 0 Rotated Property Function Specifies whether the image on the display panel is to be rotated 180 degrees Type Enum no_yes byte Value Range 0 NO Not rotated default 1 YES Rotated 180 degrees See Also Preparing the Display for Operation...

Страница 445: ...to lcd width 1 y Y coordinate of the pixel Value range is 0 to lcd height 1 Details Interpretation of the dt argument depends on the selected controller panel S election is made through the Customize Platform dialog accessible through the Project Settings dialog The dt argument is of word type but only lcd bitsperpixel lower bits of this value will be relevant All higher bits will be ignored For m...

Страница 446: ...acing lcd textverticalspacing Details Lcd printaligned fits the text within a specified rectangular area Lcd textalignment defines how the text will be aligned within this area The property has no bearing on the output produced by lcd print Texthorizontalspacing Property Function Specifies the gap in pixels between characters of text output produced by the lcd print and lcd printaligned methods Ty...

Страница 447: ...the output produced by lcd print because this method always creates a single line output Unlock Method Function Unfreezes display output on controllers panels that support this feature Syntax lcd unlock Returns See Also Details When the display is locked see lcd lock you can make changes to the display data without showing these changes on the screen You can then unlock the display with lcd unlock...

Страница 448: ...ight 1 Details The line is drawn with the specified line widht lcd linewidth and pen color lcd forecolor Drawing horizontal lcd horline or vertical lines is more efficient than drawing generic lines lcd line and should be used whenever possible The display panel must be enabled lcd enabled 1 YES for this method to work Width Property Function Sets the horizontal resolution of the display panel in ...

Страница 449: ...ach other whenever necessary Here is what the fd object has to offer Maintains up to 64 files located in a single root directory subdirectories are not supported but can be emulated Flexible file attributes define and store any attributes you like Methods to work with the file directory Ability to open several files at once Methods to write to and read from the file also cut the file size from the...

Страница 450: ...you please with the data area you have The second way is file based you create a full blown flash disk that maintains a simple file system This introduces a certain overhead since the file system needs a number of sectors for its own internal housekeeping At the same time using files may be infinitely more convenient as many complex operations happen automatically and on the background thus simpli...

Страница 451: ...ble to grow without corrupting the data area Fd Object s Status Codes Many things can go wrong when working with the flash memory This is why most methods of the fd object return a status code Good Tibbo Basic application doesn t just assume that all will be well and always checks the status of method execution Listed below are possible status codes retuned by fd object methods Of course not every...

Страница 452: ... fatal codes is generated the flash disk is dismounted automatically and the fd ready R O property is set to 0 NO The concept of disk mounting is explained in Mounting the Flash Disk File based Access The following topics will explain how to work with the flash disk Formatting the Flash Disk Mounting the Disk File Names and Attributes Checking Disk Vitals Creating Deleting and Renaming Files Readi...

Страница 453: ...ng sectors required for the disk The economy is not dramatic but you can still save some space Each file record occupies 64 bytes so one sector of the FRT table can store 4 file records For this reason the number of files you specify will always be adjusted to be the multiple of 4 For example format a disk to occupy 3 4th of available space and store at least 10 files If fd format fd availableflas...

Страница 454: ...on the maximum number of files you need to store on the disk FAT area Each FAT sector consists of 128 FAT entries 2 bytes per entry Therefore each FAT sector can fit the allocation data for 128 sectors from the data area of the disk To improve sector leveling the number of sectors allocated for the FAT area is again doubled against what s necessary So for every 128 sectors in the data area of the ...

Страница 455: ...rfectly Now there is no good solution for 1301 sectors If you give this extra one sector to the data area then you will need two more sectors for the FAT area and you don t have those sectors Allocating this extra sector to the FA is useless because you are not increasing the number of data sectors so you don t really need an extra FAT sector Hence the value of 1301 is actually not suitable to us ...

Страница 456: ...tive and can include any characters except obviously the space This includes and The flash disk does not support subdirectories but it is possible to emulate them by including or characters in the file name The character can be used to so you can have any extension s you like The attributes portion of the string may contain any characters whatsoever It is quite common for file systems to define at...

Страница 457: ...Then File1 dat is the file name R 25 JUL 2008 attributes some problem End If If fd create File2 PL_FD_STATUS_OK Then no attributes defined for this file Notice leading spaces they will be removed some problem End If If fd create Database users dat PL_FD_STATUS_OK Then and here we emulate a directory some problem End If If fd create file 3 PL_FD_STATUS_OK Then if the idea was to create a file 3 fil...

Страница 458: ...1 s R 1 0 Then delete the file only if there is no R in the attributes fd delete File1 dat End If You can set new change attributes with the fd setattributes method If fd setattributes File1 dat D PL_FD_STATUS_OK Then the attribute string will now consist of a single D some problem End If Remember that the file name and the attributes share the same 56 byte string in the file record table of the f...

Страница 459: ...r next cycle since the number of currently stored files can be checked through the fd getnumfiles method walk through the file directory method 2 Dim s As String Dim f As Byte fd resetdirpointer For f 1 To fd getnumfiles s fd getnextdirmember If fd laststatus PL_FD_STATUS_OK Then some problem End If process the file name in s Next f Opening Files You must first open a file in order to work with it...

Страница 460: ... this will generate the 11 PL_FD_STATUS_ALREADY_OPENED error You may reopen the same file on the same file number but this can lead to the loss of some changes made to the file prior to re opening To avoid this close the file or use the fd flush method before opening it again Note that the fd flush method does not depend on the current fd filenum value and works globally on any most recently chang...

Страница 461: ...iary storage for the sector data When you access a certain data sector the contents of this sector are loaded into the RAM buffer automatically When you change the data in the sector it is the data in the RAM buffer that gets changed The changed contents of the RAM buffer will not be saved back to the flash memory until the contents of another sector must be loaded into the buffer So for example i...

Страница 462: ...3 remove three front sectors from the file that is remove up to 3 256 768 bytes of data The size of the file will be corrected downwards in accordance with the amount of removed data For example performing fd cutfromtop 2 on a file occupying 3 data sectors will reduce its size by 512 bytes amount of data in 2 sectors removed Performing fd cutfromtop 3 will set the file size to 0 The pointer positi...

Страница 463: ...cord with desired field value All you need to achieve this is to have record fields occupy fixed offsets within records For example supposing you have the data table consisting of records with the following structure Field name Offset in bytes Length in bytes Category 0 1 ID code 1 11 Last name 12 21 First name 43 21 with respect to the beginning of the record Each record of this data table occupi...

Страница 464: ...les are closed using the fd close method The method is performed on a currently selected file selection is made through the fd filenum property Proper file closing is only required if you made changes to the file If you only read data from the file you don t have to bother closing it you can open another file right on the same file number Doing so on a file that was changed may cause some recent c...

Страница 465: ...from logical sector 3 fd buffernum 0 select RAM buffer 0 If fd getsector 3 PL_FD_STATUS_OK Then flash failure End If s fd getbuffer 20 10 now s contains desired data Since the sector and RAM buffer size exceeds 255 bytes maximum length of string variables you can t actually read the whole sector contents in one portion At least two fd getbuffer reads are necessary for that To modify the data in th...

Страница 466: ...ndary will result in the 1 PL_FD_STATUS_FAIL status code If you want to alter the data in the firmware application area see Upgrading the Firmware Application topic If you are using direct sector access and file based access at the same time be sure to read about ensuring their proper coexistence Using Checksums When dealing with the flash memory it is very often desirable to make sure that the da...

Страница 467: ...this the fd checksum method that can be used to both verify and calculate the checksum of the sector s data Load sector 10 verify its checksum alter some data recalculate the checksum and save new data Dim i As word load the sector If fd getsector 10 PL_FD_STATUS_OK Then flash failure End If verify the checksum If fd checksum PL_FD_CSUM_MODE_VERIFY i OK Then checksum error detected End If fd setbu...

Страница 468: ...ers are assigned to the sectors in reverse so storing to sector 0 actually means storing to the topmost physical sector of the flash memory It goes without saying that your data area has to have enough capacity to store the new binary image Exactly how you receive the new binary image is immaterial to this discussion You can use any suitable transmission method such as TCIP IP FTP your own proprie...

Страница 469: ... method does not cause any interference with the flash disk so it can be used freely The fd checksum will write to the RAM buffer when in the PL_FD_CSUM_MODE_CALCULATE mode but the checksum calculation method is the same as the one used by the disk itself so setting this checksum will never be wrong Note finally that any file related method will affect the value of the fd buffernum Never assume th...

Страница 470: ... The data area of the disk has limited leveling that results in spreading unused sector utilization The fd object makes sure that when your file needs a new data sector this data sector will be selected from a pool of available data sectors in a random fashion Once the data sector has been allocated to a file however it stays with that file for as long as necessary So if you are writing at a certa...

Страница 471: ... flash disk to fit The calculation for the housekeeping area size can be found in the Disk Area Allocation Details topic Before creating deleting files make a backup copy of the FAT FRT data Dim f As Byte backup disk housekeeping data fd buffernum 0 For f 0 To fd numservicesectors 1 fd getsector f fd setsector fd totalsize f Next f Should the need arise you can copy the data back Of course you wil...

Страница 472: ... executed or the property will return a meaningful data S means that executing the method affects fd laststatus and may also affect fd ready In other words method execution may fail so the fd laststatus will carry the error code and depending on the error the disk may be dismounted O means that the file must be opened on a currently selected fd filenum for the method to be successfully executed or...

Страница 473: ...hod M S O fd fileopened R O Property fd filesize R O Property M O fd cutfromtop Method M S O fd setfilesize Method M S O fd pointer R O Property M O fd setpointer Method M S O fd getdata Method M S O fd setdata Method M S O fd find Method M S O fd sector R O Property M O Availableflashspace R O Property Function Returns the total number of sectors available to store application s data Type Word Va...

Страница 474: ...ion for fd setbuffer and fd getsector methods or the data source for fd getbuffer fd setsector and fd checksum methods All file based operations of the flash disk rely on these two RAM buffers too and selected buffer number may change as a result of their execution When using direct sector access and file based access concurrently switch to the RAM buffer 0 for direct sector access this will guara...

Страница 475: ...the checksum was found to be wrong When the mode 1 PL_FD_CSUM_MODE_CALCULATE the method will return a newly calculated checksum Details Each physical sector of the flash memory has 264 bytes of data The flash disk of the fd object uses 256 bytes to store the data and two of the remaining 8 bytes at offsets 256 and 257 counting from 0 are used to store the checksum of the data This is an arbitrary ...

Страница 476: ...d number of sectors starting from logical sector 0 into the firmware and Tibbo Basic area of the flash memory then reboots the device to make it run the new firmware Syntax fd copyfirmware numsectors as word Returns See Also Upgrading the Firmware Application fd buffernum fd getbuffer fd getsector Part Description num sect ors Number of sectors to copy Details This method allows you to remotely up...

Страница 477: ...ceeded total number of sectors allocated to this file Details While the fd setfilesize allows to remove data from the end of the file the fd cutfromtop allows to remove data from the beginning of the file Removed data sectors previously allocated to this file will be released marked unused as they become unnecessary The file however will always have at least one data sector allocated to it That is...

Страница 478: ...nally attributes separated from the file name by a space File names are case sensitive Details The file_attr string will always be truncated to 56 characters Leading spaces will be removed The file name must contain at least one character or 4 PL_FD_STATUS_INV_PARAM code will be returned The file name must be unique attempting to create another file with the same name will lead to the 5 PL_FD_STAT...

Страница 479: ...TATUS_FORMAT_ERR Disk formatting error has been detected fatal 8 PL_FD_STATUS_NOT_READY The disk is not mounted 9 PL_FD_STATUS_NOT_FOUND File not found See Also Creating and Deleting Files Par t Description na me A string 1 56 characters with the file name All characters after the first space encountered excluding leading spaces will be ignored File names are case sensitive Details The file string...

Страница 480: ...o open a file on the currently selected file number Many file related operations such as fd setdata or fd close as well as properties such as fd filesize cannot be used unless there is an opened file on a currently selected file number Filesize R O Property Function Returns the size in bytes of the file opened on the currently selected file number selection is made through the fd filenum or zero i...

Страница 481: ...or has been detected in one of the disk sectors fatal 3 PL_FD_STATUS_FORMAT_ERR Disk formatting error has been detected fatal 4 PL_FD_STATUS_INV_PARAM Invalid argument have been provided 8 PL_FD_STATUS_NOT_READY The disk is not mounted See Also Searching Files Par t Description fro mp os Starting position in a file from which the search will be conducted File positions are counted from 1 Will be c...

Страница 482: ...shes the changes made to the most recently edited file Syntax fd close as pl_fd_status_codes Returns One of the following pl_fd_status_codes also affects fd laststatus 0 PL_FD_STATUS_OK Completed successfully 1 PL_FD_STATUS_FAIL Physical flash memory failure fatal See Also Writing To and Reading From Files Details When any sector of the flash disk is being altered this is done in a RAM buffer To i...

Страница 483: ... will allow to create Actual maximum number of files will be adjusted automatically to be a multiple of four and not exceed 64 for example specifying 6 will result in the actual value of 8 If you specify 0 you will get 4 files Details Actual usable capacity fd capacity of the formatted disk will be less than its total size This is because the disk also includes housekeeping sectors see fd numservi...

Страница 484: ... automatically be truncated to the capacity of the receiving string variable The attributes string can be defined for the file when creating the file using the fd create method or set afterwards with the fd setattributes method This method returns its execution status indirectly through the fd laststatus R O property The file with the specified name must exist or the 9 PL_FD_STATUS_NOT_FOUND statu...

Страница 485: ... opened on a currently selected file number selection is made through the fd filenum Syntax fd getdata maxinplen as byte as string Returns The string with the data read from the file The method 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 2 PL_FD_STATUS_CHECKSUM_E...

Страница 486: ...eespace as word Returns 0 65535 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 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 8 PL_FD_STATUS_NOT_RE...

Страница 487: ...ill allow you to read out the names of all files currently found on the disk Use fd resetdirpointer beforehand to move the pointer back to zero To get the names of all files you can invoke the fd getnextdirmember repeatedly until the empty string is returned or for the fd getnumfiles number of times This method returns its execution status indirectly through the fd laststatus R O property All poss...

Страница 488: ...buffer fd checksum Par t Description nu m Sector to read from Details Each physical sector of the flash memory has 264 bytes of data and all 264 bytes will be loaded into the RAM buffer Note that reading the sector into the RAM buffer 1 may interfere with file based access to the flash memory If you have executed fd setdata the RAM buffer 1 may still contain this new data in which case using the f...

Страница 489: ...TATUS_NOT_FOUND File not found 10 PL_FD_STATUS_NOT_OPENED No file is currently opened on the current value of the fd filenum property 11 PL_FD_STATUS_ALREADY_OPENED This file is already opened on some other file number See Also Fd Object s status codes Details Some methods such as fd create return execution status directly For those the fd laststatus will contain the same status as the one directl...

Страница 490: ..._codes also affects 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 3 PL_FD_STATUS_FORMAT_ERR Disk formatting error has been detected fatal See Also Mounting the Flash Disk Details The flash disk will not be accessible unless it is mounted usi...

Страница 491: ...name on a currently selected file number selection is made through the fd filenum Syntax fd open byref name as string as pl_fd_status_codes Returns One of the following pl_fd_status_codes also affects 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 ...

Страница 492: ...o See Also Writing To and Reading From Files fd sector Details For the files of 0 size see fd filesize the pointer will always be at 0 If the file has non zero size the pointer can can be between 1 and fd filesize 1 1 is the position of the first byte of the file The last existing byte of the file is at position equal to the value of fd filesize Fd filesize 1 is the position at which new data can ...

Страница 493: ... Part Description old_ nam e A string 1 56 characters with the name of the file to be renamed All characters after the first space encountered excluding leading spaces will be ignored File names are case sensitive new _na me A string 1 56 characters with the new name for the file All characters after the first space encountered excluding leading spaces will be ignored Details A file can always be ...

Страница 494: ...is method before repeatedly invoking fd getnextdirmember in order to obtain the list of files currently stored on the disk Sector R O Property Function Returns the physical sector number corresponding to the current position of the file pointer Type Word Value Range 0 65535 See Also Writing To and Reading From Files Ensuring Disk Data Integrity Details Because the sectors belonging to a given file...

Страница 495: ...sensitive attr A string with attributes to be set Attributes length cannot exceed 55 characters minus the length of the file name Details The file with the specified name must exist or the 9 PL_FD_STATUS_NOT_FOUND status code will be returned All other possible error states are generic and are not described here Setbuffer Method Function Writes a specified number of bytes into the currently select...

Страница 496: ...ds before invoking the fd getsector All status codes generated by this method are generic and are not described here Setdata Method Function Writes data to a file opened on a currently selected file number selection is made through the fd filenum Syntax fd setdata byref data as string as pl_fd_status_codes Returns One of the following pl_fd_status_codes also affects fd laststatus 0 PL_FD_STATUS_OK...

Страница 497: ...ough the fd filenum Syntax fd setfilesize newsize as dword as pl_fd_status_codes Returns One of the following pl_fd_status_codes also affects 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 3 PL_FD_STATUS_FORMAT_ERR Disk formatting error has b...

Страница 498: ...iting To and Reading From Files fd sector Par t Description pos Desired new pointer position Supplied value will be corrected if out of range Details For the files of 0 size see fd filesize the pointer may only have one value 0 If the file has non zero size the pointer can be between 1 and fd filesize 1 1 is the position of the first byte of the file The last existing byte of the file is at positi...

Страница 499: ...ation 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 This is done to prevent your applications from inadvertently damaging its own code or the firmware If you want to write into the firmware application area use fd copyfirmware instead Flash area lying within th...

Страница 500: ...bility to auto disable the keypad when a certain key event code combination is encountered 8 3 14 1 Possible Keypad Configurations The kp object works with a matrix keypad formed by scan and return lines The keypad object supports up to 8 scan and 8 return lines which means that you can build a keypad with up to 64 keys A sample schematic diagram for a typical keypad is shown below During the scan...

Страница 501: ...d drive LEDs One such LED can be connected to each scan line preferably through a buffer as shown on the drawing below These LEDs can be used for any purpose you desire and this purpose can be completely unrelated to the keypad itself If the LED is connected as shown on the drawing you need to set the corresponding I O line LOW in order to turn this LED on Each time the kp object is to scan the ke...

Страница 502: ...you might just as well ground this single scan line of the keypad i e keep it active permanently This arrangement is shown on the drawing below Preparing the Keypad for Operation topic explains how to setup the kp object properly for the keypad hardware you are using 8 3 14 2 Key States and Transitions Each key on your keypad can be in five different states as defined by the pl_kp_event_codes cons...

Страница 503: ...keypad buffer is cleared and each key s state is set to longreleased Press the key long enough and the key will go into the pressed state From there the key can go to released and later longreleased if you let go of that key or into longpressed and then repeatpressed if you keep the key pressed Five available key states along with adjustable state transition times allow you to create sophisticated...

Страница 504: ...t matter Select any lines order then in any way you want The only limitations are You can t have more than 8 scan lines and 8 return lines You must have at least 1 return line Any given I O line can only serve as a scan or return line not both Line numbers are platform dependent They come from pl_io_num found in the Platform dependent Constants section of your platform documentation The pl_io_num ...

Страница 505: ...y useful Supposing you have an application where you need to enter a certain code then press ENTER After you press ENTER your application processes the input which may take some time What you often need is to prevent any further keypad input while the code is being processed If you do not do this the user might continue punching away and creating garbage input that your system does not need This m...

Страница 506: ... lines are numbered in the same order they are listed in the kp scanlinesmapping and kp returnlinesmapping properties For example supposing you have a 4x4 keypad with 0 9 keys also F1 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 497 496 ...

Страница 507: ... launches the mysterious process_it procedure when the ENTER key is pressed Sub On_kp key_event As pl_kp_event_codes key_code As Byte Dim x As Byte If key_event PL_KP_EVENT_PRESSED Then Select Case key_code Case h1 x 1 Case h11 x 2 Case h21 x 3 Case h2 x 4 Case h12 x 5 Case h22 x 6 Case h3 x 7 Case h13 x 8 Case h23 x 9 Case h33 x 0 Case h32 CANCEL inp_str Exit Sub Case h31 ENTER will disable the k...

Страница 508: ...full list of codes 15 and 20 are key codes So the keypad will be disabled kp enabled set to 0 NO when the key with code 15 is detected to be pressed or the key with code 20 is detected to be longreleased The kp autodisablecodes string should only contain a list of decimal numbers That is use 2 and not 2 PL_KP_EVENT_PRESSED Only numerical characters are processed anyway writing 2 PL_KP_EVENT_PRESSE...

Страница 509: ...n 10ms increments the amount of time a key should remain pressed for the key state to transition from pressed into longpressed Type Byte Value Range 0 254 Default 100 1000ms See Also Key States and Transitions Preparing the Keypad for Operation Details The on_kp event with 3 PL_KP_EVENT_LONGPRESSED event code will be generated once the key transitions into the longpressed state This property can o...

Страница 510: ...state 2 PL_KP_EVENT_PRESSED The key has transitioned into the pressed state 3 PL_KP_EVENT_LONGPRESSED The key has transitioned into the longpressed state 4 PL_KP_EVENT_REPEATPRESSED Auto repeat for the key key_code Key code byte Bits 7 4 of this code represent scan line number bits 3 0 return line number Details Pressing and releasing any key on the keypad can generate up to five different events ...

Страница 511: ...or Operation Details The on_kp event with 2 PL_KP_EVENT_PRESSED event code will be generated once the key transitions into the pressed state This property can only be changed when the keypad is disabled kp enabled 0 NO Setting the property to 0 means that the key will never transition into the pressed state Releasedelay Property Function Defines in 10ms increments the amount of time a key should r...

Страница 512: ...numbers for example 24 26 27 Line numbers correspond to those of the pl_io_num enum This enum is platform specific The declarations for the pl_io_num can be found in the Platform dependent Constants section of your platform documentation The kp returnlinesmapping string should only contain a list of decimal numbers That is use 24 and not 24 PL_IO_NUM_24 Only numerical characters are processed anyw...

Страница 513: ...ers are processed anyway writing 28 PL_IO_NUM_28 30 PL_IO_NUM_30 will set this property to 28 30 You can of course write str 28 PL_IO_NUM_28 str 30 PL_IO_NUM_30 as well The order in which you list the scan lines does matter this is the order in which the lines will be numbered All keys connected to the first scan line will have their scan field bits 7 4 of the key code set to 0 For keys connected ...

Страница 514: ...d with the now obsolete WA1000 add on board This transition has caused certain changes in how the wln object works These changes are detailed in Migrating From the WA1000 topic 8 3 15 1 Migrating From the WA1000 This topic details the differences between the previous and current incarnation of the wln object This difference is related to switching to the new GA1000 hardware The old WA1000 Wi Fi ad...

Страница 515: ...rt Creating Own Ad hoc Network wln networkstart Terminating Own Ad hoc Network wln networkstop are completely new topics wln associationstate now has a new state 2 PL_WLN_OWN_NETWORK Wln defaultibsschannel is gone wln networkstart takes this as argument 8 3 15 2 Overview If you are new to Wi Fi communications then we recommend you to read the Wi Fi Parlance Primer that will introduce you to some i...

Страница 516: ...domness built in More on this here http en wikipedia org wiki BSSID Basic_service_set_identifier Channel Wi Fi devices operate on one of 14 preset frequencies Channel refers to the channel number not the actual frequency used Depending on the locale you can be restricted to fewer channels http en wikipedia org wiki List_of_WLAN_channels RSSI Stands for Received Signal Strength Indication This is a...

Страница 517: ...finement Just making sure that the previous task has competed will not guarantee that your next task will be accepted This is because some tasks can only be accepted under certain additional conditions For example you can t scan while being associated with a wireless network or running an ad hoc network of your own Try this and the wln scan will return 1 REJECTED A MUCH BETTER WAY While wln task P...

Страница 518: ...ch time a task is completed Completed_task argument of the event handler carries the code of the event that has been completed Therefore you can advance through steps in this manner THIS CODE TAKES FULL ADVANTAGE OF THE EVENT DRIVEN NATURE OF THE SYSTEM Sub On_sys_init wln settxpower 14 issue the task and don t wait End Sub Sub On_wln_task_complete completed_task As pl_wln_tasks Select Case comple...

Страница 519: ...te into the booted state is through a successful boot The process is described in Bringing Up Wi Fi Interface The key method for the process is wln boot There is no special method for powering down Your application can only reboot the 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...

Страница 520: ...Brining Up Wi Fi Interface A number of steps have to be taken in order to bring up the Wi Fi interface The following is a simplified code that demonstrates the process Typically the code would be in the on_sys_init event handler We call the code simplified because it does not check for any error conditions The code includes the following steps Allocating buffer memory Applying reset Configuring In...

Страница 521: ...sk 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 End Sub Allocating Buffer Memory The first step is to allocate memory for a single buffer required by the wln object This buffer is used to form outgoing packets and is necessary for correct operation You never have to deal with this buffer directly it is handled internally by the wln...

Страница 522: ...12 bytes Hence maximum payload size cannot exceed 412 bytes For TCP communications the size of individual packets is not that critical The beauty of TCP is that it can work with whatever buffer space is available It is true that the bigger the buffer the better TCP throughput is In reality you will stop feeling any improvement in TCP performance once your wln buffer size exceeds 2 or 3 pages The U...

Страница 523: ...erface needs its own MAC and the Wi Fi port is no exception The wln mac property exists for this purpose Your Wi Fi module already carries a MAC address onboard it is preset during manufacturing so you don t actually have to take care of the MAC Leave the wln mac at its default pre boot value of 0 0 0 0 0 0 boot up the Wi Fi interface wln boot and the wln mac will be updated with the pre assigned ...

Страница 524: ...o set a correct domain for your Wi Fi device This is done through the wln domain property Supported domains are FCC EU JAPAN and OTHER Booting Up the Hardware Booting up the Wi Fi hardware is done through the wln boot method The Wi Fi hardware does not have a ROM or flash memory and its internal processor executes its firmware from RAM Before the Wi Fi module can start working you need to upload t...

Страница 525: ...tside of your LAN Note that the IP gateway IP and netmask of the Wi Fi interface can t be set when there is at least one open socket in your system sock statesimple 0 PL_SSTS_CLOSED for any socket Setting TX Power Optional The output power of the Wi Fi hardware can be adjusted in 12 steps The wln settxpower method is provided for that purpose The power value roughly corresponds to dB The lowest ou...

Страница 526: ...know what SSID in wln scanresult means How about BSSID or RSSI The Wi Fi Parlance Primer will tell you what it all means Setting WEP Mode and Key If the network you are associating with creating uses is supposed to be using WEP then you need to set the WEP prior to associating with creating the network The wln setwep method allows you to specify the key and the WEP mode Note that wln setwep is a w...

Страница 527: ...is through scanning The wln scan fills out wln scanresultbssid wln scanresultchannel and wln scanresultbssmode R O properties You only need to put them to good use as shown here connect to the access point named TIBBO wln wepmode PL_WLN_WEP_MODE_DISABLED This one has WEP switched off don t even count on it in real life wln scan TIBBO scanning for a specific network will give us necessary parameter...

Страница 528: ...municating via Wln Interface Actual data exchange over the Wi Fi link falls outside the responsibilities of the wln object This is the task of the sock object This object has a set of properties that define whether a particular socket will be listening on the Wi Fi interface sock allowedinterfaces property establish an outgoing connection through the Wi Fi interface sock targetinterface property S...

Страница 529: ...ng off of the Wi Fi hardware On_wln_event event is fired up if either condition is detected in response to this event your application can re initialize the Wi Fi hardware and or re associate with the wireless network 8 3 15 3 Properties Methods Events Properties methods and events of the wln object Associate Method Function Causes the Wi Fi interface to attempt association with the specified wire...

Страница 530: ... 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 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 Task completion does not imply success association res...

Страница 531: ...interface which involves sending to the Wi Fi hardware a firmware file for its embedded processor Syntax wln boot offset as dword as ok_ng Returns One of ok_ng constants 0 OK completed successfully 1 NG boot failed See Also Booting Up the Hardware Part Description offset Offset of the ga1000fw bin file within the compiled binary of your project The offset is obtained using the romfile offset read ...

Страница 532: ...is no need to allocate any buffer for packet reception Buffer allocation will not work if the Wi Fi hardware is already operational wln enabled 1 YES Executing sys buffalloc at this time will leave the buffer size unchanged Therefore buffer allocation must happen before the Wi Fi hardware is booted up with the wln boot method Actual current buffer size can be verified through the wln buffsize read...

Страница 533: ...hip select CS input of the Wi Fi module s SPI interface Type Enum pl_io_num byte Value Range Platform specific See the list of pl_io_num constants in the platform specifications Default PL_IO_NULL NULL line See Also Configuring Interface Lines Details This selection cannot be changed once the Wi Fi hardware is already operational wln enabled 1 YES Correct mapping must be specified before attemptin...

Страница 534: ... NO The method will return 0 ACCEPTED if the task is accepted for processing 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 Additionally the on_wln_event event will be generated with PL_WLN_EVENT_DISASSOCIATED argument Domain Property Function Selects the domain area of the world in which this devic...

Страница 535: ...lection cannot be changed once the Wi Fi hardware is already operational wln enabled 1 YES Correct mapping must be specified before attempting to boot the Wi Fi hardware or wln boot will fail Enabled R O Property Function Indicates whether the Wi Fi interface is operational Type Enum no_yes byte Value Range 0 NO default The Wi Fi interface is not operational 1 YES The Wi Fi interface is operationa...

Страница 536: ... Range Any valid IP address such as 192 168 100 40 Default 1 0 0 1 See Also Setting IP Gateway and Netmask wln gatewayip wln netmask Details This property can only be written to when no socket is engaged in communications through the Wi Fi interface i e there is no socket for which sock statesimple 0 PL_SSTS_CLOSED and sock currentinterface 2 PL_INTERFACE_WLN Mac Property Function Sets returns the...

Страница 537: ...d netmask such as 255 255 255 0 Default 0 0 0 0 See Also Setting IP Gateway and Netmask wln ip wln gatewayip Details This property can only be written to when no socket is engaged in communications through the Wi Fi interface i e there is no socket for which sock statesimple 0 PL_SSTS_CLOSED and sock currentinterface 2 PL_INTERFACE_WLN Networkstart Method Function Causes the Wi Fi interface to att...

Страница 538: ...auses the Wi Fi interface to commence the termination of its own ad hoc network Syntax wln networkstop as accepted_rejected Returns One of accepted_rejected constants 0 ACCEPTED 1 REJECTED See Also Terminating Own Ad hoc Network Wln Tasks Details Ad hoc network termination process is a task As such the wln networkstop will be rejected return 1 REJECTED if another task is currently in progress The ...

Страница 539: ...leted this task is initiated by the wln associate method 3 PL_WLN_TASK_SETTXPOWER TX power adjustment task completed this task is initiated by the wln settxpower method 4 PL_WLN_TASK_SETWEP WEP mode and keys setup task completed this task is initiated by the wln setwep method 5 PL_WLN_TASK_DISASSOCIATE Disassociation task completed this task is initiated by the wln disassociate method 6 PL_WLN_TAS...

Страница 540: ...auses the Wi Fi interface to commence either the search for available wireless networks or obtainment of additional information about a particular network specified by its SSID Syntax wln scan byref ssid as string as accepted_rejected Returns One of accepted_rejected constants 0 ACCEPTED 1 REJECTED See Also Scanning for Wi Fi Networks Wln Tasks Part Description ssid Network name Details If the ssi...

Страница 541: ...ticular network wln scan with the ssid specified this property will contain the BSSID MAC address of this network Type Dot decimal string Value Range Standard 6 byte MAC value See Also Scanning for Wi Fi Networks wln scanresultbssmode wln scanresultchannel wln scanresultrssi wln scanresultssid Details This property will not be updated if the wln scan method is invoked with its ssid argument left e...

Страница 542: ...ved from this network Type Byte Value Range 0 255 See Also Scanning for Wi Fi Networks wln scanresultbssid wln scanresultbssmode wln scanresultchannel wln scanresultssid Details This property will not be updated if the wln scan method is invoked with its ssid argument left empty Another read only property wln rssi reports the signal strength of the network the Wi Fi interface is associated with or...

Страница 543: ...iption level Value between 4 and 15 that roughly corresponds to the transmitter s output power in dB Attemting to specify the leven 4 results in level 4 attempting to specify the level 15 results in level 15 Adjusting TX power is a task As such the wln settxpower will be rejected return 1 REJECTED if another task is currently in progress The task will also be rejected if the Wi Fi hardware is not ...

Страница 544: ...such the wln setwep will be rejected return 1 REJECTED if another task is currently in progress The task will also be rejected if the Wi Fi interface is in the associated state wln associationstate 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...

Страница 545: ...d by wln networkstart 7 PL_WLN_TASK_NETWORK_STOP Ad hoc network termination task is in progress initiated by wln networkstop See Also Wln Tasks Details The wln object will only accept another task for execution after the previous task has been completed wln task 0 PL_WLN_TASK_IDLE Whenever a task completes an on_wln_task_complete event is generated Wepkey1 Property Obsolete This parameter is now s...

Страница 546: ...ual Every topic was updated and edited Added Migrating From the WA1000 to address the changes in the wln object operation Configuring CS Line renamed into Configuring Interface Lines Powering Down renamed to Rebooting Detecting Disassociation or Powerdown renamed into Detecting Disassociation or Offline State Enabling Port renamed into Applying Reset New Creating Own Ad hoc Network and Terminating...

Страница 547: ...c Changes in the ser object manual There is a new data sinking feature so Sinking Data and sock sinkdata topics were added Corrected schematic diagram C in the Wiegand Mode topic 31AUG2008 release Documented kp object lcd object Documented md5 sha1 ddstr and ddval syscalls Documented sys serialnum and sys setserialnum Added Serial Number topic Added Using Preprocessor and Scope of Preprocessor Dir...

Страница 548: ... manual to reflect newly supported I O lines 49 53 Added to Understanding TCP Reconnects topic section about reconnects and HTTP Note added also to Sock reconmode Property topic Improved Supported Functions and Supported Objects topics for all platforms 04SEP2007 release Extended and renamed the Project Browser topic formerly called Using the Project Browser Also made new screenshot New screenshot...

Страница 549: ...ovided more info on how watch works Scopes in Watch topics provided more info on how watch works Updated Using the Project Browser selected platform is now visible in the topmost tree node Updated Program Structure explained that event handlers can also accept arguments New Exceptions topic Updated Variables and Their Types added info about dword long real float and structures Updated Type Convers...

Страница 550: ...Cfloat Function ftostr Function Lbin Function Lhex Function Lstr Function Lstri Function Lval Function Strtof Function topics Updated Vali Function topic this function is no longer available since val function now works both for word unsigned and short signed conversions Updated Val Function topic to reflect the fact that this function is now used both for word unsigned and short signed conversion...

Страница 551: ...SR lines were shown at incorrect positions Corrected ser txlen ser txfree sock txlen sock txfree property descriptions These properties do not take into account uncommitted data in the TX buffer it was stated otherwise previously Consequently these topics were also edited Buffer Memory Status TX and RX Buffer Memory Status Ser notifysent on_ser_data_sent sock notifysent on_sock_data_sent ser setda...

Страница 552: ...2000 2008 Tibbo Technology Inc Mincount Function Minutes Function Month Function Year Function 11JAN2006 release Improved indexes better context search Added L1008 L1009 02JAN2006 release Initial release of manual 203 203 204 211 112 112 ...

Страница 553: ...n HTTP file 318 BASIC files 15 baudrate 224 baudrate property 236 Beep 387 beep divider 388 beep play 389 Beeper 387 bin 190 blocking code 301 blue line 31 boolean 43 Break 28 breakpoint 30 Broadcast 281 buffer memory 213 buffer overruns 244 307 buffer redirection 308 buffer shorting 224 308 buffer sizes 224 buffers 213 Button 272 button time 274 Buzz 10 Buzzer 387 By Reference 64 By Value 64 byte...

Страница 554: ...daycount 192 ddstr 192 ddval 193 Debug Mode 27 114 Debug version 15 Decision Structures 67 Declares 79 Declaring Procedures 62 Declaring Variables 57 default gateway 267 dim 81 direction control via RTS 224 do 82 doevents 68 82 320 Double Quote Marks 40 DS202 134 dynamic HTML 74 315 320 E Edit Mode 114 EEPROM 380 else 89 elseif 89 EM1000 139 EM1000 EV 139 EM1202 149 EM1202 EV 149 EM200 134 EM202 1...

Страница 555: ...483 file pointer 375 firewall 9 firmware file 9 for 86 form 323 freeze 301 ftostr 194 Full duplex 224 Function 87 Function Procedures 62 G GIF 314 Global Scope 57 Global Variables 39 goto 88 graceful disconnect 278 green LED 384 green status 28 GUI 113 H half duplex 224 halt 217 Handling RX buffer overruns 244 Header files 15 hex 195 hours 195 hover your mouse 24 HTML 74 314 dynamic content 74 dyn...

Страница 556: ...ill 417 lcd filledrectangle 418 lcd fontheight 418 lcd fontpixelpacking 419 lcd forecolor 419 lcd getprintwidth 420 lcd greenbits 420 lcd height 421 lcd horline 421 lcd inverted 422 lcd iomapping 422 lcd line 422 lcd linewidth 423 lcd lock 423 lcd lockcount 424 lcd paneltype 424 lcd pixelpacking 425 lcd print 425 lcd printaligned 426 lcd rectangle 427 lcd redbits 427 lcd rotated 428 lcd setfont 42...

Страница 557: ...on_pat 386 on_ser_data_arrival 258 On_ser_data_arrival Event 241 on_ser_data_sent 258 on_ser_esc 259 on_ser_overrun 259 on_sock_data_arrival 342 on_sock_data_sent 342 on_sock_event 343 on_sock_inband 343 on_sock_overrun 343 on_sock_tcp_packet_arrival 344 on_sys_init 212 220 on_sys_timer 220 on_wln_event 522 on_wln_task_complete 523 OR Operator 99 P parity 224 passive open 278 Passive TCP connectio...

Страница 558: ...r getdata 253 ser interchardelay 254 ser interface 255 ser mode 255 ser newtxlen 256 ser notifysent 257 ser num 257 ser numofports 258 ser parity 260 ser redir 260 ser rtsmap 261 ser rxbuffrq 262 ser rxbuffsize 262 ser rxclear 263 ser rxlen 263 ser send 264 ser setdata 264 ser txbuffrq 265 ser txbuffsize 266 ser txclear 266 ser txfree 266 ser txlen 267 serial port 225 serial port object 224 Serial...

Страница 559: ...buffrq 361 sock tx2len 362 sock txbuffrq 362 sock txbuffsize 363 sock txclear 363 sock txfree 363 sock txlen 364 sock varbuffrq 365 socket automatic switching 276 stack pointer 31 state 28 Statements 79 status bar 126 status messages 28 stepping 32 stor base 381 stor get 381 stor set 382 stor size 383 str 207 strgen 207 stri 208 string 43 strsum 209 strtof 209 sub 93 Sub Procedures 62 SYN SYN ACK ...

Страница 560: ...ciationstate 514 wln boot 515 wln bssmode 515 wln buffrq 516 wln buffsize 516 wln csmap 517 wln defaultibsschannel 517 wln disassociate 518 wln domain 518 wln enabled 519 wln gatewayip 520 wln ip 520 wln mac 520 wln netmask 521 wln rssi 524 wln scan 524 wln scanresultbssid 525 wln scanresultbssmode 525 wln scanresultchannel 526 wln scanresultrssi 526 wln scanresultssid 526 wln settxpower 527 wln s...

Отзывы: