Serial Port Interrupts and io.intenabled

The ser. object uses your device's interrupt lines in three cases:


The same set of interrupts lines is available to your application through the io. object, its io.intnum and io.intenabled properties, and the io_on_int() event.

Depending on the platform, the use of interrupt lines by the ser. object and the use of interrupt lines by the io. object may be either independent or interdependent.


Platforms With Independent Handling of ser. and io. Interrupts

On such platforms, you can enable and disable interrupt lines (through io.intnum and io.intenabled) without disturbing the operation of the serial port. For example, if a serial port on the EM1000 is running in the Wiegand mode and uses the interrupt line 0 as a W0&1in line, you can enable this interrupt line in the io. object, then disable it, and the operation of the serial port won't be disturbed.

At the same time, the use of an interrupt line by the serial port does not show in the value of the io.intenabled property.


Platforms With Interdependent Handling of ser. and io. Interrupts

On some platforms (for example, the TPP2) the ser. object openly uses the io. object's interrupts. The rules:


This Test Code Shows the Difference

Run the following test code on a device with dependent interrupts (such as the EM1000) and a device with interdependent interrupts (such as the EM2000).

Tibbo BASIC
sub on_sys_init()
   ser.num=0                              'for clarity
   ser.mode=PL_SER_MODE_WIEGAND               'this will require the use of the interrupt line 0
   ser.enabled=YES
   
   io.intnum=0                              'for clarity
   
   if io.intenabled=NO then
      sys.debugprint("Int line 0 appears disabled, even though the serial port 0 is using it.\x0D")
      sys.debugprint("Enabling the int line 0...\x0D")
      io.intenabled=YES                     'enable the line
   else   
      sys.debugprint("Int line 0 is enabled -- this is because the serial port 0 is using it.\x0D")
   end if

   sys.debugprint("Now will try to disable the line...\x0D")
   io.intenabled=NO
   
   if io.intenabled=NO then
      sys.debugprint("The int line 0 was successfully disabled.\x0D")
   else   
      sys.debugprint("The int line 0 is still enabled (ser. object is preventing this.\x0D")
      
      sys.debugprint("Disable serial port and try again...\x0D")
      ser.enabled=NO
      
      if io.enabled=NO then
         sys.debugprint("Now that the serial port is closed the int line is disabled.\x0D")
      else   
         sys.debugprint("Hmmmm.... how did this happen.\x0D")
      end if
   end if
end sub

Here is the Debug pane output for the EM1000:

Int line 0 appears disabled, even though the serial port 0 is using it.
Enabling the int line 0...
Now will try to disable the line...
The int line 0 was successfully disabled.

And now for the EM2000:

Int line 0 is enabled -- this is because the serial port 0 is using it.
Now will try to disable the line...
The int line 0 is still enabled (ser. object is preventing this.
Disable serial port and try again...
Now that the serial port is closed the line is disabled.

Serial Port Interrupts and io.intenabled

Platforms With Independent Handling of ser. and io. Interrupts

Platforms With Interdependent Handling of ser. and io. Interrupts

This Test Code Shows the Difference