HPlogo Asynchronous Serial Communications Programmer's Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 5 Using Subsystem Break

Subsystem Break Intrinsics

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

When you want to make subsystem break processing available in a program there are several intrinsics that you must call. These intrinsics enable subsystem break and set up the procedure that will execute if the subsystem break character is entered while the program is running.

You use the XCONTRAP intrinsic to specify the address of the break handler subroutine that will execute when the user presses subsystem break. This subroutine is called the [CTRL]Y trap procedure, and the call to XCONTRAP is referred to as "arming the [CTRL]Y trap". No subsystem break processing can occur unless this trap is armed by your program through a call to XCONTRAP. Only one [CTRL]Y trap handler can be active at any given time for a process.

You use the FCONTROL intrinsic to enable subsystem break processing. You must issue a call to FCONTROL with a controlcode value of 17 for the subsystem break signal to be recognized by the program. This is true even if the [CTRL]Y trap is already armed.

You use the RESETCONTROL intrinsic to reset the trap procedure after a subsystem break has occurred. Once subsystem break is invoked, the program will not respond to another subsystem break signal until RESETCONTROL is called.

There are also several other intrinsics that you can use to control how subsystem break processing occurs.

When you enable transparent editing mode, either through a call to FCONTROL with a controlcode value of 41, or FDEVICECONTROL using a control directive of 15, you are required to enter a value for the subsystem break character through one of the parameters of the call. You can specify any character not otherwise recognized as a special character in transparent mode as the new subsystem break character, including [CTRL]Y. (If you use a value of 0 for the subsystem break character, subsystem break processing will be disabled.)

You can also specify a new character to be used as the subsystem break character in either standard or transparent editing mode by calling FDEVICECONTROL using a control directive of 41.

Finally, you can call FDEVICECONTROL using a control directive of 57 to determine the current value of the subsystem break character. This FDEVICECONTROL function provides Read access only.

Refer to Chapter 8 “Intrinsics Reference” in this manual, for descriptions of the syntax and parameters of each of these intrinsics, as well as for additional information regarding their use.

Subsystem Break Example

The code samples shown in the following figures, illustrate how you might provide subsystem break capabilities in a program. The figures show two procedures, one to handle the subsystem break itself, and one to set up and enable subsystem break.

The sample procedure in Figure 5-1 “Illustrating a Subsystem Break Handler” is a break handler routine. This is the procedure to which XCONTRAP will pass control when the subsystem break signal is sent from a user's terminal. Control might be passed at any point in the execution of the process.

In this example, when the break handler gets control from XCONTRAP, it writes a message to the user's terminal to verify that a subsystem break has occurred. The handler then takes whatever action is coded as the appropriate subsystem break response for the program. Finally, the break handler calls RESETCONTROL, and checks for successful completion before the procedure ends, (using the Pascal/iX ccode function). If the RESETCONTROL intrinsic does not complete successfully, the procedure will notify the user that the attempt to reenable subsystem break failed.

Note that the RESETCONTROL call does not have to be included in the break handling procedure. You can call RESETCONTROL from any place in the application (keeping in mind that it must execute before another subsystem break is to be allowed). However, the break handler is a convenient place to put the call if you want to make sure of its timely execution.

Figure 5-1 Illustrating a Subsystem Break Handler

Illustrating a Subsystem Break Handler

The procedure illustrated by Figure 5-2 “Procedure to Enable Subsystem Break” shows the other half of what you must do to provide subsystem break capabilities in a program. This procedure sets up and enables subsystem break.

The procedure first calls XCONTRAP, which passes the address of the [CTRL]Y procedure shown in Figure 5-1 “Illustrating a Subsystem Break Handler”. This arms the [CTRL]Y trap (enables the subsystem break handler). The Pascal/iX waddress function is used to pass the address in this example.

The address of the break handler is passed in the plabel parameter of the XCONTRAP intrinsic. The oldplabel parameter will return the address of the old trap handler, if one was previously armed. If there was no previous address, this parameter will return a 0.

After XCONTRAP executes, the procedure checks to make sure it completed successfully. Again, the procedure uses the Pascal/iX ccode function to check for errors. If XCONTRAP did not complete successfully, the user is informed of the failure, and the procedure ends.

If the call to XCONTRAP is successful, the procedure calls FCONTROL, using a controlcode value of 17. This call actually enables subsystem break processing and makes it possible for the application to respond if [CTRL]Y is entered. Again, the procedure checks for errors following the call and will inform the user should the attempt to enable subsystem break fail.

Subsystem break can also be disabled at any time, by calling FCONTROL again, using 16 as the controlcode value.

Figure 5-2 Procedure to Enable Subsystem Break

Procedure to Enable Subsystem Break
Feedback to webmaster