243
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
Actually, this call will handle no more than 255 bytes in one pass. Even
though we seemingly copy the data directly from the RX buffer to the
TX buffer, this is done via a temporary string variable automatically
created for this purpose. In this platform, string variables cannot
exceed 255 bytes.
Polling method of data processing can sometimes be useful. See
.
Sending Data
In the previous section, we explained how to handle an incoming stream of data.
You could say it was incoming-data driven. Sometimes you need just the opposite
-- you need to perform operations based on the sending of data.
For example, supposing that in a certain system, 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, obviously, you need to make sure that the TX buffer has
the necessary amount of free space before sending. A simple polling solution would
look like this:
sub
on_button_pressed
dim
s
as
string
s =
"This is a long string waiting to be sent. Send me already!"
while
ser.txfree < len(s)
'we will wait for the necessary amount of
free space to become available
wend
ser.setdata(s)
ser.send
end
sub
Again, this is not so good, as it would block other event handlers. So, instead of
doing that, we would employ a code that uses
:
320
258