214
Platforms
©2000-2008 Tibbo Technology Inc.
serial port of the ser object, or particular socket of the sock object, etc. to which
the buffer you are trying to change belongs. "Idle" means different things for
different objects:
= 0- NO for the serial port,
=
0- PL_SSTS_CLOSED for the socket, etc.
Intelligent memory allocation basing on what's available
Memory is not an infinite resource and you will not always get as much memory as
you have requested. Methods such as the
actually return the
amount of memory that can be allocated:
dim
x
as
byte
x=ser.rxbuffrq(
5
)
'x could get less than 5, which means that you got less
memory than you have asked for
Two properties of the sock object were implemented to help you allocate memory
intelligently, basing on what is available.
read-only property tells you how many buffer pages are
there on 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).
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 four serial ports and four sockets:
dim
x,f
as
byte
x=sys.totalbuffpages/
16
'will work correctly if we haven't allocated
anything yet
for
f=
0
to
3
ser.num= f
ser.rxbuffrq(x)
ser.txbuffrq(x)
sock.num= f
sock.rxbuffrq(x)
sock.txbuffrq(x)
next
f
In the above example we do not check what individual buffer requests return
because we have already calculated each buffer's size basing on the total number
of buffer pages available.
System Timer
The system object provides a timer event-
- that is generated
periodically. The period depends on the platform. If the platform doesn't have a
property, then this period is fixed at 0.5 seconds. If the
251
358
262
223
218
220
220