235
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
Can you tell what serial port the statement above applies to? Neither can the
platform. Thus, the correct syntax would be:
ser.num =
0
ser.mode =
PL_SER_MODE_WIEGAND
Now the platform knows what port you're working with. Once you have set the port
selector (using ser.num), every method and property after that point is taken to
refer to that port. Thus:
ser.num =
0
ser.enabled =
1
ser.baudrate =
1
ser.bits =
1
' etc
The events generated by the ser object are not separate for each port. An event
such as
serves all serial ports on 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, the ser.num property retains its new value (nothing changes it
back). You must take this into account when processing other event handlers
which make use of the serial port (and are not serial port events). In other words,
you should explicitly set the ser.num property whenever entering such an event
handler, because the property might have been automatically changed prior to this
event. To illustrate:
258