background image

Содержание 9000 Series 300

Страница 1: ... and User Interfacing HP UX Concepts and Tutorials HP 9000 Series 300 800 Computers HP Part Number 97089 90057 FliOW HEWLETT a e PACKARD Hewlett Packard Company 3404 East Harmony Road Fort Collins Colorado 80525 ...

Страница 2: ...opyright All rights are reserved Reproduction adaptation or translation without prior written permission is prohibited except as allowed under the copyright laws Restricted Rights Legend Use duplication or disclosure by the U S Govern ment Department of Defense is subject to restrictions as set forth in para graph b 3 ii of the Rights in Technical Data and Software clause in FAR 52 227 7013 Use of...

Страница 3: ... 1 This edition supersedes manual part number 97089 90054 The current edition contains all information previously contained in the Device I O and the Curses and Terminfo tutorials In addition the manual reflects the following changes Examples in the Device I O tutorial have been updated to reflect changes for the 7 0 release The Curses and Terminfo tutorial now includes 16 bit character support Th...

Страница 4: ......

Страница 5: ...tions 1 6 Handshake I O 1 7 Handshake Output 1 7 Handshake Input 1 7 HP IB Protocol 1 8 The HP IB Interface 1 9 General Structure 1 9 Handshake Lines 1 10 Bus Management Control Lines 1 13 ATN The Attention Line 1 14 IFC The Interface Clear Line 1 14 REN The Remote Enable Line 1 14 EOI The End or Identify Line 1 14 SRQ The Service Request Line 1 15 The GPIO Interface 1 15 2 General Purpose Routine...

Страница 6: ...ing Minimum Data Transfer Rate Setting the Read Termination Pattern Termination on Byte Count Termination on Hardware Condition Termination on Data Pattern Disabling a Read Termination Pattern Determining Why a Read Terminated Example Interrupts Series 300 and 800 Interrupt Support HP IB Interrupts GPIO Interrupts io_on_interrupt io_interrupt_ctl 3 Controlling the HP IB Interface Overview of HP IB...

Страница 7: ... HP IB 3 11 io_lock and io_unlock 3 12 io_burst 3 12 hpib_io 3 12 Opening the HP IB Interface File 3 13 Sending HP IB Commands 3 13 Errors While Sending Commands 3 16 Changing Parity on Commands 3 17 Active Controller Role 3 17 Determining Active Controller 3 18 Setting Up Talkers and Listeners 3 19 Auto Addressing 3 19 Using hpib_send_cmnd 3 22 Calculating Talk and Listen Addresses 3 23 An Exampl...

Страница 8: ...Interface Bus Address System Controller Role Determining System Controller System Controller s Duties hpib_abort hpib_ren_ctl Errors During hpib_abort and hpib_ren_ctl The Computer As a Non Active Controller Checking Controller Status Requesting Service Errors While Requesting Service Responding to Parallel Polls Calculating the Response Limitations of hpib_card_ppolLresp Error Conditions hpib_ppo...

Страница 9: ...nterface Performing Data Transfers Using Status and Control Lines Driving CTLO and CTLI Reading STIO and STll Controlling Data Path Width Controlling Transfer Speed GPIO Timeouts Burst Transfers Read Terminations Determining Why a Read Operation Terminated Specifying a Read Termination Pattern Interrupts A Series 300 Dependencies Location of the DIL Subroutines Linking DIL Subroutines The GPIO Int...

Страница 10: ...ccessing the Interface Special Files Major Numbers Minor Numbers and Logical Unit Numbers Listing Special Files Naming Conventions for Interface Special Files Creating Interface Special Files Hardware Effects on DIL Routines hpib_rqst_srvce hpib_io hpib_atn_ctl hpib address_ctl hpih_parity_ctl io_eoLctl io_reset io_speed_ctl io_timeout_ctl io_width_ctl Return Values for Special Error Conditions DI...

Страница 11: ...errupt Performance Tips Process Locking Setting Real Time Priority Preallocating Disc Space Reducing System Call Overhead Setting Up Faster Data Transfers C ASCII Character Codes D DIL Programming Example B 10 B 10 B 10 B 10 B 11 B 11 B 12 B 12 B 12 B 13 B 14 B 14 Contents 7 ...

Страница 12: ......

Страница 13: ...amples shown in this tutorial are written in C but the techniques illustrated are easily converted for use with Pascal or FORTRAN by adding a little extra code Variation Between Computer Systems In general DIL subroutines function identically on all HP UX computers regardless of series or model number within a series However because of certain inherent differences between processors and other hard...

Страница 14: ...ubroutines when used with Series 300 computers If you are using a Series 300 HP UX system check this appendix to ensure correct use of DIL subroutines Appendix B Series 800 Dependencies is similar to other appendices but for Series 800 computers Use this appendix to ensure the correct use of DIL subroutines on Series 800 systems Appendix C Character Codes Appendix D DIL Programming Example shows a...

Страница 15: ... DIL subroutines to a compiled C program invoke the C compiler as follows cc program c ldvio Similarly for a Pascal program use pc program p ldvio and for a FORTRAN program use fc program f ldvio In all three cases the I option is passed to the HP UX linker causing it to link any DIL routines called by the program being compiled To determine the exact location of DIL library on your HP UX system r...

Страница 16: ...hem by reference This incompatibility can be easily circumvented by directing the compiler to generate a call by value through the use of FORTRAN s ALIAS option For example ALIAS close close val If the FORTRAN compiler on your system does not support this form of ALIAS the parameter passing differences can be resolved by writing an onionskin routine which is a C language function written for the p...

Страница 17: ...s from the peripheral device to a form that can be used by the computer The interface also controls information transfer paths and transfer timing such that data flows in an orderly manner in correct sequence HP 9000 computers are equipped with both built in as well as plug in interfaces that can be purchased as standard or optional items Separate interface cabling connects the peripheral device s...

Страница 18: ...rammer are responsible for general data format communication protocols such as those used in data communication networks and HP IB interconnections are usually managed by the interface card based upon various signals and commands from the computer and the peripheral device Timing Compatibility Peripheral devices within a given system rarely have identical data transfer rates and data transfer timi...

Страница 19: ...ol signal from computer and transfers data to output drivers and interface cable Interface asserts output timing signals to peripheral device and waits for response Peripheral accepts output timing signals inputs data from interface cable then returns flag signal indicating data has been accepted Interface recognizes flag and sets flag to computer indicating the transaction is complete If the send...

Страница 20: ...cting demands from the two processors and the increased efficiency of a smart interface greatly reduces the complexity and overhead related to more mundane approaches to interrupt driven handshake I O For example instead of handling each character or word as a single transaction the computer can load a block of data into the shared memory then signal the interface that data is ready for transfer T...

Страница 21: ...ion rules called bus protocol that governs data and control operations on the bus The defined protocol is necessary in order to ensure orderly information traffic over the bus Each device peripheral or computer interface that is connected to the HP IB can function in one or more of the following roles System Controller Master controller of the HP IB The computer interface is usually the bus contro...

Страница 22: ...pt data from the bus such as a line printer usually operates as a listener while a device that can only supply data to the bus such as a voltmeter usually operates as a talker However before any device can talk or listen after power up initialization it must be authorized to do so by the current active controller Bus configuration varies depending on the type of activity that is prevalent at the t...

Страница 23: ...ym such as DAV NRFD NDAC etc When discussing these same signal lines in hardware documents it is customary to refer to ground true low true logic lines by their name acronym with a bar across the top such as DAV NRFD NDAC etc In this document both versions are used The overbar is usually present when discussing hardware operation but usually absent when software is being treated In this tutorial o...

Страница 24: ...e low simultaneously or later in a given handshake cycle The line then remains low until every device that was previously pulling the line low has released the line allowing it to float to its high state At the start of the handshake cycle point A the handshake lines are in the following states DAV is false high meaning that the current talker has not yet placed valid data on the bus NRFD is true ...

Страница 25: ...ter driving NRFD low each listener inputs and processes the data from the data lines When it has accepted the data the listener releases NDAC As with the NRFD line at point B NDAC remains low true until every listener on the bus has released the line allowing it to go high false When NDAC goes high the false logic state indicates to the talker that every listener has accepted the data point E When...

Страница 26: ...nated the System Controller becomes the Active Controller and any current talker and all listeners become unaddressed Normally this line is used to terminate all current operations or to allow the System Controller to regain control of the bus It overrides any other activity currently taking place on the bus REN The Remote Enable Line This line allows instruments on the bus to be programmed remote...

Страница 27: ...be serviced However the device continues to assert SRQ until it has been satisfied or until an interface clear command disables the request Exactly what satisfies a service request depends on the requesting device and is explained in the operating manual for the device The GPIO Interface The GPIO General Purpose Input Output interface is a very flexible parallel interface that can be used to commu...

Страница 28: ......

Страница 29: ...grams Specifically the following topics are presented Basic introductory background concepts that are essential to understanding correct use of DIL library routines Opening interface special files Closing interface special files Read write operations to interface special files Designing error checking routines Resetting an interface Controlling input output parameters Determining why a read termin...

Страница 30: ...ing interface special files on your system Entity Identifiers eid Nearly all DIL routines require an entity identifier eid as a parameter The entity identifier is an integer returned by the open 2 system call when opening the interface special file eid is the file descriptor for the opened special file on Series 300 and 800 The eid supplied as a parameter to a DIL subroutine tells the subroutine w...

Страница 31: ...eout_ctl Establish a timeout period for any operation performed on a specified interface by a DIL routine io_width_ctl Set the data path width for a specified interface io_speed_ctl Select a data transfer speed for a specified interface io_eol_ctl Set up a read termination character for data read from a specified interface io_get_term_reason Determine how the last read terminated for the specified...

Страница 32: ...tine handles high speed transfers on both HP IB and GPIO I O io_dma_ctl Control usage of DMA channels by DIL devices Refer to the io_burst 3I and io_dma_ctl 3I entries in the HP UX Reference for details on using these subroutines Opening Interface Special Files With the exception of the default standard input standard output and standard error files all read write operations to any file from insid...

Страница 33: ...is required as a parameter in all DIL subroutine calls It is also required as a parameter for all read write operations to the opened file The following code defines an entity identifier called eid and opens an interface file called dev raw_hpib with access enabled for both reading and writing include fcntl h include errno h int eid eid open dev raw_hpib O_RDWR Special files can also be opened by ...

Страница 34: ...of the configurable parameter ndilbuffers default is 30 See the HP UX System Administrator Manual for information on changing this value Series 800 systems limit the number of open DIL files to 16 per interface The close system call requires the entity identifier corresponding to the open interface special file that is being closed The following code segment shows how to open and close an HP IB in...

Страница 35: ...handled at a fairly high level where the system automatically provides buffering and other services that are not under the direct control of the user or program being run However some situations that are commonly encountered by DIL users require a much more intimate control of individual I O transactions These low level operations provide no buffering or other services and are a direct entry into ...

Страница 36: ...om a previously opened 1 I file with the entity identifier eid 1 Calls to write are very similar include fcntl h include errno h mainO int eid I the entity identifier 1 char buffer 1 the buffer containing data to be written to a file 1 if eid open dev raw_hpib O_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 1000000 I establish communication with the HP IB interfa...

Страница 37: ...is example 14 characters are sent through eid The literal string expression This is a test is placed in a data storage area by the compiler for later handling by the call to write On output if the number of characters requested does not match the length of the data storage space the message is truncated if the byte count is smaller than the data block or extended into the next data block assigned ...

Страница 38: ...include adequate error checking However most examples shown in this tutorial other than in this section do not verify successful completion of subroutine calls Refer to the errno 2 entry in the HP UX Reference for complete definitions of the various errors returned when a system call fails Using errno The following code segment must be present in the early part of any program that accesses errno i...

Страница 39: ...iled then print out the value of errno and exit if it did The following example illustrates this strategy include errno h include fcntl h mainO int eid if eid open II dev raw_hpibll O_RDWR 1 printf Error occurred Errno d errno exit 1 When this method is used the program user must refer to the errno 2 entry in the HP UX Reference to determine what the printed value of errno means General Purpose Ro...

Страница 40: ...pen 2 in the HP UX Reference reveals that errno is set to ENOENT defined in the errno h header file if you attempt to open a file that does not exist and you have not given the system call permission to create a new file Armed with this information you can incorporate the following code segment in your program include errno h include fcntl h maine int eid if eid open dev raw_hpib O_RDWR 1 if errno...

Страница 41: ...ion about the exact effects of io_reset on HP IB and GPIO interfaces when used with various computer models For example suppose that after opening an interface file you want to make sure the interface has been properly initialized This is done by calling io_reset and looking at its return value include fcntl h include errno h main int eid if eid open dev raw_hpib D_RDWR 1 printf open failed errno ...

Страница 42: ...e O_NDELAY flag was set during the call to open 2 and the interface is locked any attempts to access the locked interface fail and the DIL subroutine call from the process returns with an error Locks on an interface are owned by the process and are not associated with the eid This means that the same process can access a given interface through another eid if another open is performed on the devic...

Страница 43: ... io_eol_ctl Read Termination Pattern Assign a pattern to be recognized as a read termination pattern Note It is not uncommon for a single process to have multiple eids open simultaneously resulting from multiple calls to open in a single program The subroutines io_timeout_ctl io_width_ctl io_speed_ctl and io_eol_ctl can be used to conveniently configure different values for timeout width speed and...

Страница 44: ...rrno h mainO int eid long time if eid open II dev raw_hpibll O_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid time 1000000 set timeout of 1 second data transfers using eid are controlled by the timeout value time eid is the entity identifier associated with the open interface file and time is a 32 bit long integer specifying the length of the timeout in microseconds Each time an I O...

Страница 45: ...device can respond with data in less than zero time For this reason the default or a specified timeout value of zero is treated as a request to disable timeout and any condition that would normally cause a timeout termination is ignored by the system usually causing the program to hang Specifying a timeout of zero is not recommended Any interface file eid obtained by using the dup 2 system call or...

Страница 46: ...ault lower 8 bits use a a code segment similar to the following include fcntl h include errno h maine int eid width width 16 width of new data path if eid open dev raw_hpib O_RDWR 1 printf IIopen failed errno d n errno exit 2 io_width_ctl eid width assign new width for GPIO bus data transfers using dev raw_gpio will now use a 16 bit bus Use of io_width_ctl to change interface data path width affec...

Страница 47: ...system selects a transfer method that is as fast or faster than the requested speed If the requested speed is beyond system limitations the fastest available transfer method is used Refer to the appropriate hardware specific appendix for details Setting the Read Termination Pattern During read operations on an open device file the system recognizes certain conditions as the end of a data transfer ...

Страница 48: ... one or two bytes only as the end of the incoming data For instance if an HP IB interface detects that the EOI line has been asserted it knows that the last data byte has been transferred and halts the read operation whether or not the specified byte count has been reached Termination on Data Pattern The DIL routine io_eol_ctl configures an interface to recognize a particular character or pair of ...

Страница 49: ...es a currently active termination condition can cause a read operation to halt independent of whether the defined eol condition has been met Also note that the read termination pattern defined by iO_901_ctl is accepted as part of the valid incoming data meaning that it is transferred to the data storage area along with the rest of the transferred data In other words when the interface encounters t...

Страница 50: ...in the stored data message An interface file entity identifier returned by a dup 2 system call or inherited by a fork request shares the same read termination pattern as the entity identifier returned by the original call to open If the child process resulting from a fork inherits an entity identifier then sets a read termination pattern for that eid the eid used by the parent process is also affe...

Страница 51: ...I character decimal value 46 as a termination pattern performs a read operation then disables termination pattern recognition include fcntl h include errno h maine int eid char buffer 12 if eid open dev hpib_dev O_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 10000000 io_eol_ctl eid 1 46 read eid buffer 12 Read operation halts when a period character is read or w...

Страница 52: ...ination 2 End of line character pattern caused termination 4 Device imposed condition such as EOI asserted on HP IB interface caused termination If more than one termination condition occurred simultaneously the bit corresponding to the above values is set for each condition and the aggregate value of the lower three bits represents a sum equal to the combined values of the individual conditions T...

Страница 53: ...g code segment provides that capability include fcntl h include errno h 1 possible termination reasons returned by io_get_term_reason 1 define TR_ABNORMAL 0 1 abnormal 1 define TR_COUNT 1 1 requested count was satisfied 1 define TR_MATCH 2 1 specified eol character was matched define TR_CNT_MCH 3 1 TR_COUNT TR_MATCH 1 define TR_END 4 1 EO was detected 1 define TR_CNT_END 5 1 TR_COUNT TR_END 1 defi...

Страница 54: ...NT TR_MATCH 1 printf Count and EOL character satisfied n break case TR_END 1 EO was detected 1 printf EO detected n break case TR_CNT_END 1 TR_COUNT TR_END 1 printf Count satisfied and EO detected n break case TR_MCH_END 1 TR_MATCH TR_END 1 printf EOL character satisfied and EO detected n break case TR_CNT_MCH_END printf Count and EOL character satisfied and EO detected n break default 1 io_get_te...

Страница 55: ...IB interrupt conditions signal Condition SRQ SRQ line has been asserted TLK Computer HP IB interface has been addressed to talk LTN Computer HP IB interface has been addressed to listen CIC Computer HP IB interface has received control of the bus IFC IFC line has been asserted REN Remote enable line has been asserted DCL Computer HP IB interface has received a device clear command GET Computer HP ...

Страница 56: ...to the function that is to be invoked when the interrupt condition occurs and cause_vec is a pointer to a structure of the form struct interrupt_struct int cause int mask The interrupt_struct structure is defined in the include file dvio h cause is a bit vector specifying which selectable interrupt or fault events will cause the handler routine to be involked Available interrupt causes are usually...

Страница 57: ...andler The entity identifier eid and the interrupt condition cause are returned to handler as the first and second parameters respectively Whenever an interrupt condition occurs for a given eid the interrupt is recognized interrupts are disabled for that eid then the interrupt handler is executed After processing the interrupt interrupts can be re enabled for that eid by calling io_interrupt_ctl E...

Страница 58: ...ervice_routine handler eid cause_vec int eid struct interrupt_struct cause_vec if cause_vec cause SRQ service_routine 0 application specific service routine maine iIit eid struct interrupt_struct cause_vec if eid open ll dev raw_hpibll O_RDWR 1 printf lIopen failed errno d nll errno exit 2 io_reset eid cause_vec cause SRQ io_on_intertupt eid cause_vec handler 2 30 General Purpose Routines ...

Страница 59: ...face device file The value of enable_flag determines whether interrupts are to be enabled or disabled if enable_flag is non zero interrupts are enabled on the eid if enable flag is zero interrupts are disabled Attempting to use io_interrupt_ctl on an eid fails when no previous call has been lnade to io_on_interrupt for the same eid The following code segment shows how the previous example can be m...

Страница 60: ......

Страница 61: ...ion and control interaction between HP IB devices 3 This chapter explains the use of subroutines in the Device I O Library that are directly related to HP IB interface control Chapter 4 covers comparable material for the GPIO interface This chapter presents a brief overview of HP IB commands followed by a detailed discussion of HP IB DIL subroutines including how they are used to control bus activ...

Страница 62: ... enable line REN enabled by the System Controller unless altered by the System Controller REN is enabled by default Only the System Controller can alter the state of the REN line see System Controller s Duties section later in this chapter HP IB Data Bus Commands fall into four categories Universal commands cause every properly equipped device on the bus to perform the specified interface operatio...

Страница 63: ...in hpib_send_cmnd subroutine calls Table 3 1 HP IB Bus Commands Decimal Command Value ASCII Character Universal Commands UNLISTEN 63 UNTALK 95 DEVICE CLEAR 20 DC4 LOCAL LOCKOUT 17 DC1 SERIAL POLL ENABLE 24 CAN SERIAL POLL DISABLE 25 EM PARALLEL POLL UNCONFIGURE 21 NAK Addressed Commands TRIGGER 8 BS SELECTED DEVICE CLEAR 4 EOT GO TO LOCAL 1 SOH PARALLEL POLL CONFIGURE 5 ENQ TAKE CONTROL 9 HT Contr...

Страница 64: ...ercase ASCII PARALLEL POLL DISABLE 112 p UNLISTEN UNLISTEN unaddresses all current listeners on the bus No means is available for unaddressing a given listener without unaddressing all listeners on the bus This command ensures that the bus is cleared of all listeners before addressing a new listener or group of listeners UNTALK UNTALK unaddresses any active talkers on the bus Since no means is ava...

Страница 65: ... independent of whether the devices being polled have been addressed to talk When a device is addressed to talk it returns an 8 bit status byte message This command is handled through the DIL subroutine hpib_spoll as discussed later in this chapter SERIAL POLL DISABLE SERIAL POLL DISABLE terminates serial poll mode for all devices that support this command whether or not the individual devices hav...

Страница 66: ...econdary command follows This secondary command must be either PARALLEL POLL ENABLE or PARALLEL POLL DISABLE PARALLEL POLL ENABLE PARALLEL POLL ENABLE configures devices addressed by PARALLEL POLL CONFIGURE to respond to parallel polls with a predefined logic level on a particular data line On some devices the response is implemented in a local form such as by using hardware jumper wires that cann...

Страница 67: ...tines Standard OIL Routines These 17 subroutines in addition to the general purpose subroutines discussed in Chapter 2 provide full capabilities for controlling and using the HP IB interface Controlling the HP IB Interface 3 7 ...

Страница 68: ...itiate a service request SRQ when interface is not Active Controller hpib_send_cmnd Send command message on HP IB data lines while asserting the attention ATN line hpib_wait_on_ppoll Wait until a specified device responds on its assigned parallel poll response line indicating that it needs service hpib_status_wait Wait until any device on the bus asserts SRQ hpib_ppoll_resp_ctl Configure and enabl...

Страница 69: ...r All other interfaces must be configured as non controllers incapable of acting as System Controller This is usually accomplished by programming a switch or jumper on the HP IB interface card At power up the System Controller is the Active Controller All other controllers on the bus are non active controllers If the computer interface passes control to another device the device receiving control ...

Страница 70: ...wait Note 1 hpib_ppoll_resp_ctl Note 2 hpib_parity_ctl Note 1 hpib_atn_ctl hpib_address_ctl Note 1 Note 1 This command is available to the System controller but the availability is meaningless because this command is available to any interface on the bus independent of its role as an active or non active controller Note 2 This command is available to the interface while it is active controller but...

Страница 71: ...I O Library contains several subroutines that are provided specifically for maintaining orderly HP IB traffic and good I O efficiency Correct use of these subroutines is especially important when using raw interface files They include io_lock and io_unlock to take exclusive control of the HP IB channel for the duration of a transfer io_burst to efficiently handle short transfers without consuming ...

Страница 72: ...s from using the bus while you have control As soon as the interface file is unlocked it can be accessed by the next process that needs it io_burst Series 300 systems support burst I O also called fast handshake which bypasses the kernel by performing a high speed non interrupt transfer This method can produce considerable performance improvement when handling short transfers to or from high speed...

Страница 73: ... up a character array containing the commands being sent Assign the decimal value of each command to an element in the array then use a subroutine call having the form hpib_send_cmnd eid command number where eid is the entity identifier for the open interface file command is a character pointer to the first element of the array containing the HP IB commands and number is the number of elements com...

Страница 74: ...trate the two methods assume that you want to send the HP IB UNLISTEN and UNTALK commands With the decimal array method first set up an array having two elements place the decimal value for each command in the appropriate location in the array then call hpib_send_cmnd include fcntl h include errno h maine int eid char command 2 command array if eid open dev raw_hpib O_RDWR 1 printf open failed err...

Страница 75: ...1 _ is ASCII for UNTALK 1 The array method is usually preferred when sending a large number of commands or sending the same set of commands several times in the program because the entire set of commands can be stored once then used whenever needed When the string method is used the entire set of commands must be specified as a string in each call to hpib_send_cmnd It is preferred when sending onl...

Страница 76: ...ck the value of errno an external integer variable used by HP UX system calls Error checking routines are discussed at length in Chapter 2 The following table lists errno values corresponding to the conditions above when detected by hpib_send_cmnd errno Value EBADF ENOTTY EIO Error Condition eid did not refer to an open file eid did not refer to a raw interface file The interface was not the Activ...

Страница 77: ... printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 1000000 hpib_parity_ctl eid 0 command O 63 command l 95 I decimal value for UNLISTEN I I decimal value for UNTALK I Active Controller Role The Active Controller is responsible for originating all commands handled on the bus and responding to requests for service from other devices hpib_send_cmnd is used to send HP IB comman...

Страница 78: ...nterface is the current Active Controller Use the following subroutine call form hpib_bus_status eid ACT_CONT_STATUS where eid is the entity identifier for the opened HP IB interface device file and ACT_CONT_STATUS tells the subroutine to examine interface status and determine whether or not the card is the Active Controller The value returned by the subroutine can be tested as indicated in the ex...

Страница 79: ...ted Series 300 and 800 computers provide two methods for addressing listeners and talkers on HP IB auto addressing and command addressing When an HP IB interface device file is set up as an auto addressed file determined by the value of the minor number used when creating the file any read write operations to or from the file automatically set up the bus talk and listen address commands prior to t...

Страница 80: ...w or auto addressed by the minor number used when the file is created Address 31 hexadecimal If is reserved for raw files Any address in the range 0 through 30 is auto addressed Refer to the appropriate appendix for procedures used to create device and interface special files For example suppose you are using a Series 300 computer with an HP 98624 HP IB card on select code 08 to access a periphera...

Страница 81: ... addressable The following code segment illustrates how to use auto addressing with such a device file include errno h include fcntl h mainO int eid if eid open l dev device O_RDWR 0 printf Open of dev device failed errno d n errno exit 1 Assuming dev device has the minor number Ox080300 the system automatically addresses the interface card at select code 8 as a talker and the device at bus addres...

Страница 82: ...r a different device However not all devices are necessarily well mannered so an UNTALK is considered good programming practice To configure a new talker and listeners 1 Send an UNTALK command to remove any previous talkers 2 Send an UNLISTEN command to remove any previous listeners 3 Send the talk address of the device that will be sending data There can only be one talker 4 Send the listen addre...

Страница 83: ... HP IB addresses may be reserved for specific devices on some systems Once device addresses are known for all devices of interest setting up talk and listen addresses is a fairly simple matter HP IB commands are set up as a single ASCII character transmitted while ATN is asserted However it is usually much easier to calculate addresses based on bus address rather than looking up the corresponding ...

Страница 84: ...t establishes the interface as the bus talker Two devices at HP IB addresses 4 and 8 are designated as bus listeners include dvio h include fcntl h include errno h rnainO int eid MTA char command 5 if eid open 1 dev raw_hpib D_RDWR 1 printf lIopen failed errno d n errno exit 2 I calculate My Talk Address 1 MTA hpib_bus_status eid CURRENT_BUS_ADDRESS 64 command O 95 1 UNTALK command 1 command 1 63 ...

Страница 85: ... System Controller can assert or release the REN line REN by default is asserted at power up and remains asserted unless changed as discussed later in this chapter under the topic System Controller Operations Locking Out Local Control The LOCAL LOCKOUT command inhibits the LOCAL key or switch present on the front panel of most HP IB devices thus preventing anyone from interfering with system opera...

Страница 86: ...1 1 listen address for device at address 3 1 1 listen address for device at address 5 1 1 the GO TO LOCAL command 1 command 4 The HP IB TRIGGER command tells devices currently addressed as listeners to initiate some device d p iident action A typical use is triggering a measurement cycle on a digital voltmeter Since device response to a TRIGGER command is strictly device dependent HP IB has no dir...

Страница 87: ...n talk address MTA 4 Send the listen address of the device that is to receive the data One listen address is sent for every device that is to receive the data 5 Send the data 6 Repeat steps 1 and 2 to clean up the bus The first 3 steps are accomplished using hpib_send_cmnd The system subroutine write takes care of the fourth Controlling the HP IB Interface 3 27 ...

Страница 88: ...errno d n errno exit 2 io_reset eid io_timeout_ctl eid 1000000 MTA hpib_bus_status eid command 0 95 CURRENT_BUS_ADDRESS 64 compute MTA UNTALK command command 1 63 command 2 MTA command 3 32 5 hpib_send_cmnd eid command 4 UNLISTEN command address interface to talk listen address of device at address 5 write eid data messagell 12 send the data hpib_send_cmnd eid command 2 clear talkers and listeners...

Страница 89: ...1 if eid open II Idev raw_hpibll O_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 1000000 MLA hpib_bus_status eid CURRENT_BUS_ADDRESS 32 I compute MLA I command O 95 I UNTALK command 1 command l 63 I UNLISTEN command 1 command 2 64 5 command 3 MLA hpib_send_cmnd eid command 4 len read eid buffer 50 buffer len 0 hpib_send_cmnd eid command 2 printf Data read is S bu...

Страница 90: ...ng entity identifier eid use a code segment similar to command 0 20 DEVICE CLEAR command hpib_send_cmnd eid command 1 The second command for resetting devices is SELECTED DEVICE CLEAR This command resets only those devices that are currently addressed as listeners To reset a device at HP IB address 7 use a code segment such as this the interface must already be addressed to talk command O 63 comma...

Страница 91: ...e SRQ Line To request service a device asserts the bus Service Request SRQ line To determine if SRQ is being asserted check the status of the line wait for SRQ or set up an interrupt handler for SRQ The hpib_status_wait subroutine provides a means for suspending program operation until the SRQ line is asserted then continuing To structure a program so that it waits until SRQ line is asserted invok...

Страница 92: ...else printf Either a timeout or an error occurred n Another solution is to periodically check the value of the SRQ line by calling hpib_bus_status as follows hpib_bus_status eid SRQ_STATUS where as before eid is the entity identifier for the open interface file and SRQ_STATUS indicates that you want the logical value of the SRQ line returned hpib_bus_status returns 1 if SRQ is asserted 0 if not an...

Страница 93: ...vice before it can properly undertake any service related activity There are two strategies for doing this Serial poll each individual device in sequence until the one that is requesting service is found This approach is reasonable if there are only a few devices on the bus Conduct a parallel poll to locate the device requesting service Normally each device when capable is programmed to respond on...

Страница 94: ...pectively The next section explains how to use these subroutines Parallel Polling The parallel poll is the fastest means of determining which device needs service when several devices are connected to the bus Each device on the bus that is capable of responding to parallel polls can be programmed to respond to parallel polls by asserting a given data line thus making it possible to obtain the stat...

Страница 95: ... devices can respond on the same data line This means that only eight or fewer devices in this category can reside simultaneously on a given bus If fewer than eight are present data lines not used by these devices for parallel poll response can be shared among remaining devices on the bus if any are present Each device in this category responds to a parallel poll on an assigned data line determine...

Страница 96: ...e 16 possible combinations of lines and logic levels since there are two possible levels on each line and only one line can be asserted during a parallel poll The PARALLEL POLL ENABLE command consists of an 8 bit byte whose bits are arranged as follows the decimal equivalent value of the byte falls in the range of 96 through 111 D7 D6 D5 D4 D3 D2 Dl DO Decimal Range 0 1 1 0 L X X X 96 111 where Th...

Страница 97: ... device at bus address 5 to respond to a parallel poll by asserting data line D1 with a logic 1 if it needs service include dvio h include fcntl h include errno h mainO int eid MTA char command 50 if eid open dev raw_hpib O_RDWR 1 printf open failed errno d n errno exit 2 MTA hpib_bus_status eid CURRENT_BUS_ADDRESS 64 compute MTA command O MTA talk address of interface command l 63 the UNLISTEN co...

Страница 98: ...ndicates that the device respond with a 1 to request service Bits C through A 001 indicate that the device should respond on Dl When the computer interface is the Active Controller it can configure its own parallel poll response by addressing itself as both talker and listener However the configuration is meaningless until the interface is no longer Active Controller because the Active Controller ...

Страница 99: ...mmand 3 5 1 the PARALLEL POLL CONFIGURE command 1 command 4 112 1 the PARALLEL POLL DISABLE command 1 hpib_send_crnnd eid command 5 Conducting a Parallel Poll Once parallel poll responses have been remotely or internally configured for all devices on the bus that are capable of responding to parallel polls you can use hpib_ppoll to conduct a parallel poll on the bus provided the computer is the cu...

Страница 100: ...results of the parallel poll but does not include the code needed to handled the requested service include fcntl h include errno h mainO int eid status byte if eid open 1IIdev raw_hpib O_RDWR 1 printf lIopen failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 10000000 if status hpib_ppoll eid 1 I conduct the parallel poll 1 printf error taking ppoll n I if 1 returned then error occurred ...

Страница 101: ...efer to a raw HP IB interface file Entity identifier eid does not refer to an open file A timeout occurs To find out which of these conditions caused the error your program should check for the following values of errno errno Value EBADF ENOTTY EIO Error Condition eid does not refer to an open file eid does not refer to a raw interface file Interface is not Active Controller EACCES m Series 800 ET...

Страница 102: ... with 0 when it wants service instead of the usuall hpib_wait_on_ppoll returns the response byte XORed with the sense value then ANDed with the mask value unless an error occurs in which case it returns 1 Calculating the mask hpib_wait_on_ppoll uses only the least significant byte of the mask integer which means that the integer s remaining bytes can contain anything For simplicity the examples in...

Страница 103: ...e sense integer For simplicity the examples in this discussion set the upper bytes to zero The value for sense is determined as follows 1 Decide which parallel poll lines the 8 data lines are to be monitored for service requests as discussed earlier 2 Determine which of these lines will indicate a service request by a logic oresponse This means that you must know the sense with which the associate...

Страница 104: ... on the other hand all of devices request service with a 0 the sense value can always be 255 11111111 in binary You need calculate a special value for sense only if various devices on the bus respond with dissimilar logic senses Example Assume that you want to use hpib_wait_on_ppoll to wait for one of the four devices on a bus to request service where the bus is configured as follows Parallel Poll...

Страница 105: ...en dev raw_hpib D_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 10000000 Set a 10 second timeout if hpib_wait_on_ppoll eid 15 6 1 printf either a timeout or error occurred n else service_routine In the code segment shown service_routine is executed only if one of the four devices requests service during the parallel poll service_routine should contain code segmen...

Страница 106: ... the poll causes a timeout or suspends your program indefinitely The Active Controller cannot poll itself Unlike parallel poll responses serial poll responses cannot be configured remotely by the Active Controller Responses vary depending on the type of device being polled Refer to device manual for more information Conducting a Serial Poll Subroutine hpib_spoll performs a serial poll on a specifi...

Страница 107: ...g code segment shows how hpib_spoll can be used to determine whether a device at bus address 5 is requesting service The determination is made by simply examining D6 which indicates whether SRQ is being asserted include fcntl h include errno h maine int eid status if eid open dev raw_hpib O_ROWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 100000 I Set a O 1 second t...

Страница 108: ... the range 0 30 The interface associated with this eid is locked by another process and D_NDELAY is set for this eid To determine which of these conditions caused the error your program should check for the following values of errno errno Value EBADF ENOTTY EIO Error Condition eid does not refer to an open file eid does not refer to a raw interface file The interface was not the Active Controller ...

Страница 109: ... is not suspended if the Non Active Controller that you address does not accept active control of the bus but the computer still loses active control meaning that the bus no longer has an Active Controller If this happens the computer must use its position as System Controller to assume the role of Active Controller by executing hpib_abort see System Controller Role section which follows or io_res...

Страница 110: ... is locked by another process and D_NDELAY is set for this eid To find out which of these conditions caused the error your program should check for the following values of errno errno Value EBADF ENOTTY EIO EINVAL Error Condition eid does not refer to an open file eid does not refer to a raw interface file Interface is not Active Controller Invalid bus address ETIMEDOUT A timeout occurred EIO on S...

Страница 111: ...entifier for an open interface file that is currently active controller and flag is either a 0 or a 1 A flag value of 1 enables ATN a value of 0 disables it Changing the Interface Bus Address On a Series 300 the subroutine hpib_address_ctl can be used to programmatically change the bus address of an HP IB interface card hpib_address_ctl is called as follows hpib_address_ctl eid ba where eid is the...

Страница 112: ...ass active control to another controller Determining System Controller To determine whether your computer s HP IB interface is the System Controller use the hpib_bus_status subroutine which must be called as follows where eid is the entity identifier for an open interface file and SYS_CONT_STATUS indicates that you want to determine whether it is the System Controller The subroutine returns 1 if i...

Страница 113: ...if eid open dev raw_hpib O_RDWR 1 printf open failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 1000000 if status hpib_bus_status eid SYS_CONT_STATUS 1 printf Error occurred during bus status subroutine n else if status 1 printf Interface is the System Controller n else printf Interface is not the System Controller n Controlling the HP IB Interface 3 53 ...

Страница 114: ... set by the previous Active Controller System Controller then becomes Active Controller Returns all devices on the bus to their local state hpib_abort leaves the SRQ line unchanged meaning that any device requesting service before hpib_abort is executed is still requesting service when the subroutine is finished To use hpib_abort on a particular HP IB the computer must be the System Controller of ...

Страница 115: ...ower up or reset It is also enabled whenever the System Controller executes hpib_abort To use hpib_ren_ctl on a particular HP IB the computer must System Controller on that bus It does not have to be the Active Controller hpib_ren_ctl is called as follows hpib_ren_ctl eid flag where eid is the file descriptor for an open interface file and flag is an integer If flag is zero the REN line is disable...

Страница 116: ... to an open file eid does not refer to a raw interface file Interface is not System Controller In addition hpib_abort can return the following values for errno errno Value Error Condition ETIMEDOUT A timeout occurred EIO on Series 300 EACCES The interface associated with this eid was locked by another process and D_NDELAY was set for this eid 3 56 Controlling the HP IB Interface ...

Страница 117: ...atus_question is an integer that indicates what question you want answered The value of status_question must be within the range of 0 through 7 where the relationship between value and the nature of the status inquiry are as follows Value REMOTE_STATUS SRQ_STATUS SYS_CONT_STATUS ACT_CONT_STATUS TALKER_STATUS LISTENER_STATUS CURRENT_BUS_ADDRESS Status Question Is the interface in its remote state A...

Страница 118: ...Non Active Controller n else printf Computer is the Active Controller n Requesting Service When your computer is a Non Active Controller it can request service from the current Active Controller by asserting the SRQ line This is done with the hpib_rqst_srvce routine which is called as follows hpib_rqst_srvce eid response where eid is the entity identifier for an open interface file and the lowest ...

Страница 119: ... the same bus can be handled in an orderly manner hpib_rqst_srvce returns 0 if it executes correctly or 1 if an error occurred Once you have asserted SRQ the line remains asserted until the Active Controller serially polls you or you call hpib_rqst_srvce again and clear bit 6 using a sequence such as hpib_rqst_srvceCeid 0 Once the serial poll response is configured your computer s HP IB interface ...

Страница 120: ... card for correct response to parallel polls When an HP IB device responds to a parallel poll with an I need service message the Active Controller then performs a serial poll to determine what type of service is required If two or more devices are configured to respond to a parallel poll on a single data line and the Active Controller detects a service request on that line the controller must perf...

Страница 121: ...troller the response must be configured on the interface This can be programmed remotely by the Active Controller as discussed previously in the Active Controller section of this chapter or locally using hpib_card_ppoll_resp To configure a parallel poll response Specify the logic sense of the response i e whether a 1 means the device does or doesn t need service Specify which data line the device ...

Страница 122: ...llel poll response lines DO D7 is to be used when responding to a parallel poll Of course this configuration capability is possible only on those interfaces that support it Refer to the appropriate appendix for more information about specific systems Limitations of hpib_card_ppoILresp Hardware limitations on certain devices restrict the use of hpib_card_ppoll_resp to configure parallel poll respon...

Страница 123: ...Value EBADF ENOTTY Error Condition eid does not refer to an open file eid does not refer to a raw interface file ETIMEDOUT A timeout occurred EIO on Series 300 EACCES EINVAL The interface associated with this eid was locked by another process and D_NDELAY was set for this eid The device cannot respond on the line number stecified by response hpib_ppoILresp_ctl The subroutine hpib_ppoll_resp_ctl is...

Страница 124: ...o disable responses to parallel polls from another Active Controller by using hpib_card_ppoll_resp by setting bit D4 in the routine s response value When D4 is 0 the interface is set to respond to parallel polls with a service needed logic level When D4 is 1 the interface responds to parallel polls with the opposite service not needed level Thus a flag value of 16 disables the need service respons...

Страница 125: ... by use of subroutines hpib_bus_status hpib_status_wait and io_on_interrupt hpib_status_wait has been mentioned in previous discussions about the Active Controller and System Controller The following discussion provides a look at its uses Call hpib_status_wait as follows hpib_status_wait eid status where eid is the entity identifier for an open interface file and status is an integer indicating wh...

Страница 126: ...eid 10000000 if hpib_rqst_srvce eid 64 1 set SRQ line to request service printf Error while requesting service n exit l if hpib_status_wait eid WAIT_FOR_CONTROL 1 wait until Active Controller printf Error while waiting for status n exit 1 Computer is now the Active Controller Note that for hpib_status_wait to have returned 1 caused by an unexpected timeout a timeout value would have to have been s...

Страница 127: ... to an open file eid does not refer to a raw HP IB interface file status contains an invalid value ETIMEDOUT The specified condition did not become true before a timeout occurred EIO on Series 300 EACCES EIO The interface associated with this eid was locked by another process and D_NDELAY was set for this eid The device is active controller and status specifies WAIT_FOR_TALKER or WAIT_FOR_LISTENER...

Страница 128: ...interface is not addressed as a talker n In the above call to hpib_bus_status eid is the entity identifier for the interface device file and TALKER_STATUS indicates that you want to know if it is addressed to talk The routine returns the value 1 if the answer is yes 0 if not To determine whether the interface is currently addressed as a bus listener use the following if hpib_bus_status eid LISTENE...

Страница 129: ...ner then handle an appropriate data transfer use the DIL subroutine hpib_status_wait specifying both the entity identifier of the interface device file and the bus condition that is being used to terminate the wait hpib_status_wait eid condition Controlling the HP IB Interface 3 69 ...

Страница 130: ... segment the program waits for the interface to become a bus listener then reads a 50 byte message include dvio h include fcntl h include errno h maine int eid len char buffer 51 storage for message if eid open dev raw_hpib D_RDWR 1 printf IIopen failed errno d n errno exit 2 io_reset eid io_timeout_ctl eid 5000000 5 second timeout if hpib_status_wait eid WAIT_FDR_LISTENER 1 printf Either a timeou...

Страница 131: ...ar buffer 50 main int handler 0 int eid struct interrupt_struct cause_vec if eid open IIIdev raw_hpib O_RDWR 1 printf IIopen failed errno d n errno exit 2 io_reset eid cause_vec cause LTN io_on_interrupt eid cause_vec handler handler eid cause_vec int eid struct interrupt_struct cause_vec if cause_vec cause LTN read eid buffer 50 Controlling the HP IB Interface 3 71 ...

Страница 132: ...ries of subroutine calls to io_lock hpib_send_cmnd read write and i _unlock and makes these operations atomic on the Seris 300 A call to hpib_io has the form include dvio h rnain int eid struct iodetail iovec int iolen hpib_io eid iovec iolen where eid is the entity identifier of an open interface file iovec is a pointer to an array of I O operation structures and iolen is the number of structures...

Страница 133: ...alue How many bytes are to be transferred during the I O operation A pointer to an array containing the bytes of data to be transferred Components of a particular iodetail structure are referenced with iovec component where iovec is a pointer to an array of iodetail structures and component is either mode terminator count or buf The Mode Component The mode describes what type of I O operation is t...

Страница 134: ... the EOI line is asserted when the last byte of data is sent It only has effect if you also specify HPIBWRITE If you are performing a read operation the transfer is halted when the terminator component value of the iodetail structure is read The terminator component only has effect if you OR HPIBCHAR and HPIBREAD The HPIBCHAR constant only has effect if also specify HPIBREAD When you construct mod...

Страница 135: ...component of the structure is assigned the necessary value as follows iovec mode HPIBWRITE I HPIBATN The Terminator Component The terminator component of the iodetail structure specifies a character that causes the termination of a read operation when it is detected The terminator only has effect if HPIBREAD I HPIBCHAR is specified as the structure s associated mode component Assign a value to the...

Страница 136: ... IIdata messagell Allocating Space Before building iodetail structures for I O operations storage space in memory must be allocated The easiest way to do this if you are programming in C is to write a routine that allocates space for n iodetail structures and returns a pointer to the first one Here is a sample code segment for such a routine io_alloc include dvio h struct iodetail io_alloc n int n...

Страница 137: ...third structure configures the bus so that the device at address 7 is the talker and the interface is the listener 4 The fourth structure receives the data message from the device The following code segment illustrates how the four structures can be built and implemented include fcntl h include errno h include dvio h contains definitions for iodetail struct iodetail io_alloc n int n char malloc 0 ...

Страница 138: ... structure 3 Configuring the bus 1 temp pointer 1 temp mode HPIBWRITE I HPIBATN strcpy buffer 2 1G II temp buf buffer 2 temp count strlen buffer 2 I increment structure I to send commands 1 I Build structure 4 Receiving data message 1 temp I increment structure pointer 1 temp mode HPIBREAD I read data until count limit is reached 1 temp count 10 I accept message up to 10 bytes in length 1 temp buf...

Страница 139: ...Buffered I O Operations If all I O operations specified in the array of iodetail structures complete successfully hpib_io returns 0 and updates the count component of each structure to reflect the actual number of bytes read or written If an error occurs during one of the I O operations hpib_io immediately returns a 1 indicating the error To determine which iodetail structure operation was associa...

Страница 140: ...first structure if eid open II dev raw_hpib O_RDWR printf open failed errno d n errno exit 2 1 io_reset eid io_timeout_ctl eid 10000000 if hpib_io eid iovec 10 1 execute the operations If a 1 is returned an error occurred number 1 initialize counter FOUND 0 initialize Boolean flag temp iovec set temporary pointer to first structure while number 10 FOUND 1 if temp count 1 found structure that cause...

Страница 141: ... Controlling the HP IB Interface 3 81 ...

Страница 142: ......

Страница 143: ...ual explains how each switch is used and how it should be configured Configurable functions associated with these switches include Data logic sense Data handshake mode Input data clock source Set the configuration switches according to the directions found in the GPIO interface installation manual Creating the GPIO Interface File After setting the necessary switches on your GPIO interface install ...

Страница 144: ...ps General purpose routines usable with both HP IB and GPIO interfaces GPIO routines routines specifically designed for use with a GPIO interface General purpose routines are listed and described in detail in Chapter 2 They are used in this chapter to illustrate various aspects of controlling GPIO interfaces from an HP UX process Two DIL routines used exclusively with GPIO interfaces gpio_get_stat...

Страница 145: ...he data path width and data transfer speed Set a timeout for data transfers Set a read termination character Get the termination reason Set up the interrupts Enable or disable interrupts Resetting the Interface The interface should always be reset before it is used to ensure that it is in a known state All interfaces are automatically reset when the computer is powered up but you can also reset th...

Страница 146: ...read and write system calls are used to transfer ASCII data to and from the GPIO interface The following code segment illustrates how to use these routines to write 16 bytes to the interface then read 16 bytes back in include fcntl h include errno h mainO int eid entity identifier char read_buffer 16 write_buffer 16 buffers to hold data if eid open dev raw_gpio O_RDWR 1 printf open failed errno d ...

Страница 147: ...d to CTLO bit 0 and CTL1 bit 1 Both CTLO and CTL1 are ground true logic meaning that they are at a logic LOW level when asserted This logic polarity cannot be changed Logic sense of the two lines is related to value as follows If value 0 CTLO and CTL1 both false HIGH logic level If value 1 CTLO true LOW logic level and CTL1 false HIGH logic level If value 2 CTLO false HIGH logic level and CTLI tru...

Страница 148: ...nd CTL1 STIO and STI1 are ground true logic meaning they are at a logic LOW level when asserted Thus the value returned by gpio_get_status is as follows be sure to AND value with 3 to clear upper bits before testing If value 0 STIO and STI1 both false HIGH logic level If value 1 STIO true LOW logic level and STI1 false HIGH logic level If value 2 STIO false HIGH logic level and STI1 true LOW logic...

Страница 149: ...TI1 is asserted insert code that handles case when STI1 is asserted else neither are asserted insert code that handles case when neither STIO nor STI1 is asserted Controlling Data Path Width DIL subroutine io_width_ctl is used to specify 8 bit or 16 bit data path widths for the GPIO interface The call has the following form where eid is the entity identifier for an open GPIO interface file and wid...

Страница 150: ...olling Transfer Speed You can request a minimum speed for the data transfer across a GPIO interface by issuing a call to io_speed_ctl Your system rounds the specified speed up to the nearest defined speed If you specify a speed that is faster than your system allows the highest available speed is used instead Refer to Chapter 2 for more information about io_speed_ctl GPIO Timeouts If a non zero ti...

Страница 151: ...routine io_get_term_reason described in Chapter 2 is used to determine why the last read performed on a particular eid terminated Possible reasons include The requested number of bytes were read A specified read termination character was seen A assertion of the PSTS line was seen Some abnormal condition occurred such as an I O timeout Specifying a Read Termination Pattern Chapter 2 describes subro...

Страница 152: ......

Страница 153: ... using the DIL subroutines Techniques for improving data transfer performance when using DIL subroutines Location of the OIL Subroutines The DIL subroutines that provide direct control of your computer s interfaces are contained in the library usr lib libdvio a Some of these subroutines are general purpose and can be used with any interfa te supported by the library while others provide control of...

Страница 154: ...signal lines provide additional flexibility The GPIO interface is comprised of the following lines 16 parallel data input lines 16 parallel data output lines 4 handshake lines 4 special purpose lines Data Lines There are 32 data lines 16 for input and 16 for output These lines normally use negative logic 0 indicates true 1 indicates false The logic can be changed so that a 1 indicates true with th...

Страница 155: ...ll mode handshake should be used if the peripheral does not meet the pulse mode timing requirements Refer to the GPIO interface s documentation for a description of these handshake methods Data In Clock Source Ensuring that data is valid when read by the receiving device differs slightly depending on what direction the data is flowing When writing data out from the computer the interface generally...

Страница 156: ...d pathname c major_number minor_number The c parameter to mknod tells the system to create the file as a character special file Descriptions of the remaining parameters to the mknod command follow pathname The pathname parameter specifies the name to be given to the newly created interface special file The pathname identifies the interface itself not a peripheral on the interface Special files are...

Страница 157: ...le file In this case Ad specifies the bus address of the device for which the special file is created If only one device can be connected to the interface e g the GPIO interface the component of the minor number is ignored U a single digit hexadecimal value specifying a secondary address This component of the minor number is ignored when the special file you are creating is for an interface you sh...

Страница 158: ... code 02 dev raw_hpib1 and select code 03 dev raw_hpib2 mknod dev raw_hpib1 c 21 Ox021fOO mknod dev raw_hpib2 c 21 Ox031fOO Creating a GPIO Interface File Now suppose you have a GPIO interface that you want to access with the DIL subroutines on the same computer Because the GPIO interface does not use a bus architecture the usual bus address Ad and secondary address UV components of mknod s minor ...

Страница 159: ... and creat in addition to open Restrictions Using the OIL Subroutines This section presents some restrictions on using the DIL subroutines on Series 300 computers These restrictions are organized under the routine to which they apply The subroutines are presented in alphabetical order hpib_send_cmnd By default the Series 300 HP IB interface card uses odd parity when you send commands via hpib_send...

Страница 160: ...O transfer speed is set less than 7Kb sec i e the speed parameter is less than 7 then the interface will use interrupt transfer mode If the transfer speed is set greater than 140Kb sec speed 140 then the system chooses the fastest mode possible If the speed is between 7Kb and 140Kb sec 7Kb speed 140 then DMA transfer mode is used IMPORTANT If you are using pattern termination via io_eol_ctl then y...

Страница 161: ...OCK unlock my process Use auto addressing for all read and write operations refer to Chapter 3 under the topic Setting up Talkers and Listeners Use rtprio 2 to increase the system priority of an I O process rtprio requires that the process be running with an effective user ID of super user The real time priorities available with rtprio are non degrading priorities Be careful when using real time p...

Страница 162: ...io my_proc my_proc 0 specifying process number zero tells rtprio to refer to the calling process rtprio my_proc 127 priority 127 lowest real time priority rtprio my_proc RTPRIO_RTOFF turn off real time priority A 10 Series 300 Dependencies ...

Страница 163: ...or the interfaces that you plan to use with DIL creating special files for the interfaces that you plan to use with DIL DIL routines affected by the Series 800 hardware DIL support of HP IB auto addressed files improving performance of DIL programs Compiling Programs That Use OIL The DIL routines are located in the library usr lib libdvio a Thus programs can be linked as cc test c ldvio Series 800...

Страница 164: ... major number 21 The HP IB card talks to different drivers which use different major numbers to do I O to other kinds of devices such as disc drives or printers All default special files in the dev hpib directory use major number 21 The driver that talks to the AFI card is called gpioO and corresponds to major number 22 The dev gpioO special file uses major number 22 Minor Numbers and Logical Unit...

Страница 165: ...ecial file without decoding it by hand The syntax of lssf is 1ssf f dev_fi1eJ path where path is the pathname of the special file Lssf uses the major number from the special file to find the name of the device driver in a file called etc devices If you use the f option lssf looks in dev_file instead of etc devices It then decodes the minor number outputs the logical unit number the device bus addr...

Страница 166: ...nce Naming Conventions for Interface Special Files If your Series 800 computer was configured correctly the special files discussed above will already have been created By convention HP IB special files reside in the dev hpib directory Also by convention the default special files for the HP IB raw bus a HP IB card itself are named dev hpib X where X is the bus s logical unit Auto addressed files a...

Страница 167: ...of the special file you wish to create Each class of device can have additional class dependent attributes such as the bus address for an HP IB auto addressed file For HP IB devices the driver is instrO Thus to create a special file named dev bus for HP IB lu 1 you use the command mksf d instrO 1 1 dev bus When creating auto addressed HP IB special files you add another option a to associate the a...

Страница 168: ...ric values are defined in the file usr include sys errno h hpib_rqst_srvce The hpib_rqst_srvce routine only permits bit 6 of the serial poll response to be set If hpib_rqst_srvce is called with a response having bit 6 set the interface sends 01000000 64 decimal in response to serial poll if bit 6 is not set in response the interface sends 10000000 128 decimal See The Computer as a Non Active Contr...

Страница 169: ...FIFO buffer is flushed out The io_speed_ctl routine is not supported on Series 800 computers transfer is always done via DMA On Series 800 computers the timeout you specify via io_timeout_ctl is rounded up to the nearest 10 millisecond boundary For example if you specify a timeout of 125000 microseconds 125 milliseconds the effective timeout is rounded up to 130 milliseconds DIL functions read or ...

Страница 170: ...h a given address on the bus For read and write requests to these files addressing is done automatically that is the sequence of talk and listen bus commands is generated for you In general the DIL functions are not defined for auto addressed files On the Series 800 however many of them are implemented but with more device oriented actions Important The DIL Standard does not currently specify a fu...

Страница 171: ...ib_eoLctl hpib_io hpib_pass_ctl hpib_ppoll hpib_ppoILresp_ctl hpib_ren_ctl hpib_rqst_srvce hpib_send_cmd hpib_spoll hpib_status_wait hpib_wait_on_ppoll io_eoLctl io_get_term_reason io_interrupt_ctl io_on_interrupt io_reset io_speed_ctl io_timeout_ctl io_width_ctl Those functions in the second column which operate differently on raw bus and auto addressed special files are discussed below Series 80...

Страница 172: ...hpib_ren_ctl Setting REN by setting the flag parameter to a non zero value on an auto addressed file addresses the associated device before asserting REN Clearing REN by setting flag to a zero addresses the device and sends it a Go To Local command in lieu of clearing REN hpib_send_cmd Sending HP IB commands to an auto addressed file via hpib_send_cmd does the appropriate device addressing for you...

Страница 173: ...e is polled In addition the sense argument only specifies the sense of the particular device s assertion Successful completion of the hpib_wait_on_ppoll request implies that the device responded to parallel poll io_on_interrupt The only allowable interrupt for auto addressed files is SRQ Series 800 Dependencies 8 11 ...

Страница 174: ...ystem from swapping out the process s code data or both The following example illustrates its use include sys lock h int plockO mainO plock PROCLOCK lock text and data segments into memory plock UNLOCK unlock the process Refer to plock 2 and getprivgrp 2 in the HP UX Reference for more information Setting Real Time Priority The operating system schedules processes based on their priority Under nor...

Страница 175: ...al time priority for ME rtprio ME RTPRIO_RTOFF Turn off real time priority for ME Refer to rtprio 2 and getprivgrp 2 in the HP UX Reference for more information Preallocating Disc Space if your process is reading large amounts of data and writing it to a file you can block while the operating system allocates disc space However you can allocate disc space in advance by using the prealloc system ca...

Страница 176: ...ta buffers are aligned on a page boundary The number of bytes per page is defined as NBPG and can be referenced by including sys param h The following example shows how to allocate and page align a data buffer include sys param h defines NBPG and roundup x y define REAL_SIZE 1024 amount of memory we want to page align char malloc 0 mainO char malloc_ptr align_ptr malloc_ptr malloc NBPG REAL_SIZE a...

Страница 177: ...II Control Characters Keys ASCII Dec Oct Hex Keys ASCII Dec Oct Hex I Shift OO NUL 00 000 00 I DLE 16 020 10 K SOH 01 001 01 QJ DC1 17 021 11 STX 02 002 02 DC2 18 022 12 ETX 03 003 03 W DC3 19 023 13 EaT 04 004 04 I DC4 20 024 14 I ENQ 05 005 05 NAK 21 025 15 J ACK 06 006 06 YJ SYNC 22 026 16 BEL 07 007 07 ill R ETB 23 027 17 8J BS 08 010 08 ill CAN 24 030 18 O HT 09 011 09 ill I EM 25 031 19 Q LF...

Страница 178: ...15 OD 45 00101101 055 2D LA13 SO 14 00001110 016 OE 46 00101110 056 2E LA14 SI 15 00001111 017 OF 47 00101111 057 2F LA15 DLE 16 00010000 020 10 0 48 00110000 060 30 LA16 DC1 17 00010001 021 11 LLO 1 49 00110001 061 31 LA17 DC2 18 00010010 022 12 2 50 00110010 062 32 LA18 DC3 19 00010011 023 13 3 51 00110011 063 33 LA19 DC4 20 00010100 024 14 DCL 4 52 00110100 064 34 LA20 NAK 21 00010101 025 15 PP...

Страница 179: ...0 j 106 01101010 113 4B TAll k 107 01101011 114 4C TA12 1 108 01101100 115 4D TA13 m 109 01101101 116 4E TA14 n 110 01101110 117 4F TA15 0 111 01101111 120 50 TA16 p 112 01110000 121 51 TA17 q 113 01110001 122 52 TA18 r 114 01110010 123 53 TA19 s 115 01110011 124 54 TA20 t 116 01110100 125 55 TA21 u 117 01110101 126 56 TA22 v 118 01110110 127 57 TA23 w 119 01110111 130 58 TA24 x 120 01111000 131 5...

Страница 180: ......

Страница 181: ... programs much easier 1 2 This example Amigo printer driver uses a byte stream as standard 3 input and Amigo protocol as output to HP IB driver 21 Any special 4 character handling should be done by a filter that feeds this driver 5 6 This example program is provided for solely illustrative purposes to 7 demonstrate typical use of Device I O Library OIL subroutines No 8 representations are made as ...

Страница 182: ...SCG_BASE 14 38 define PR_SEC_MASK SCG_BASE Ol 39 define PR_SEC_STRD SCG_BASE l0 2608A 40 41 output of DSJ operation 2608A 42 define PR_ATTEN OxOOOl 43 define PR_RIBBDN Ox0002 44 define PR_ATT_PAR Ox0003 45 define PR_PAPERF Ox0010 46 define PR_SELF Ox0020 47 define PR_PRINT Ox0040 48 clear 49 output of DSJ operation the rest of the printers 50 define PR_RFDATA OxOOOO 51 define PR_SDS OxOOOl 52 defi...

Страница 183: ... define printer types 76 define T2608A 1 77 define T2631A 2 78 define T2631B 3 79 define T2673A 4 80 define QjetPlus 5 81 define T2632A 6 82 define T2634A 7 83 84 int ptr_type type of printer 85 86 setup defines for fatal returns 87 define F_RTRN 1 88 define F_EXIT 0 89 90 setup defines for HP IB_msg 91 define H_READ 1 92 define H_WRITE 2 93 define H_CMND 4 94 95 default timeout value in seconds t...

Страница 184: ... MLA my listen address 117 int DTA device printer talk address 118 int DLA device printer listen address 119 120 device bus address my bus address 121 int devba myba 122 123 my name 124 char procnam 125 126 int Debug 0 127 128 main argc argv 129 int argc 130 char argv 131 132 133 register i c 134 register unsigned char outbuf output buffer pointer 135 int status 136 int selcode select code of prin...

Страница 185: ...m 168 fprintf stderr b bufsz Output buf size to printer d n bufsz 169 fprintf stderr lI_t tmout Max seconds to output buffer d n timeout 170 fprintf stderr printer_dev Printer device file s n ptr_dev 171 fprintf stderr _p ppoll_mask Parallel poll mask Ox 02x n pmask 0 172 exit 2 173 174 get memory for the output buffer 175 outbuf unsigned char malloc bufsz 4 176 177 NOTE Printer device file dev lp...

Страница 186: ... st_rdev 204 DLA LAG_BASE devba device listen address 205 DTA TAG_BASE devba device talk address 206 207 open the HP IB raw bus device 208 if eid open ptr_dev D_RDWR 0 209 fatal_err Raw HP IB open ptr_dev F_RTRN 210 fprintf stderr 211 II The following commands executed as a super user may be necessary n n 212 fprintf stderr mknod s c 21 Ox slfOO n ptr_dev ptr_raw l 213 fprintf stderr chmod 555 s n...

Страница 187: ...mmy break 231 238 printf printer n 239 240 set the timeout to user requested value 241 if io_timeout_ctl eid timeout 1000000 0 242 fatal_err io_timeout_ctl ptr_dev F_EXIT 243 244 always tag last output data byte with EOI 245 if hpib_eoi_ctl eid 1 0 246 fatal_err hpib_eoi_ctl ptr_dev F_EXIT 247 248 clear out the status bits 249 amigo_clear 250 251 check the status bits 252 status amigo_status 253 i...

Страница 188: ...1 or 2 bytes 275 int 276 HPIB_msg rw_flag pcm1 pcm2 pcm3 buffer length ocmO ocm1 277 int rw_flag 278 int pcm1 279 int pcm2 280 int pcm3 281 char buffer 282 int length 283 int ocmO 284 int ocm1 285 286 287 288 289 unsigned char pre_cmd 4 unsigned char post_cmd 2 int tlog 1 290 pre_cmd O UNL always issue unlisten command first 291 pre_cmd 1 pcm1 292 pre_cmd 2 pcm2 293 pre_cmd 3 pcm3 294 295 post_cmd...

Страница 189: ...er length 0 314 fatal_err write ptr_dev F_EXIT 315 break 316 317 case H_CMND 318 return O 319 default 320 return l 321 322 1 send the postamble 1 or 2 bytes with attention true 1 323 if hpib_send_cmnd eid post_cmd ocm1 2 1 0 324 fatal_err lIhpib_send_cmnd postamble ptr_dev F_EXIT 325 326 1 at last unlock the bus so other bus users can access it 1 327 if io_unlock eid 0 328 fatal_err io_unlock ptr_...

Страница 190: ...350 case 13 return QjetPlus 351 case 16 return T2632A 352 case 17 return T2634A 353 default 354 printf IIUnrecognized Amigo printer 102 d n 355 identify 1 break 356 357 break 358 case 33 359 if identify 1 1 360 printf Ciper printer not supported yet n 361 break 362 default 363 printf Unrecognized Amigo Printer identify 101 d 102 d n 364 identify 0 identify 1 365 break 366 367 exit 2 368 369 370 se...

Страница 191: ...tatus 395 396 unsigned char status_byte 1 397 398 HPIB_msg H_READ MLA DTA PR_SEC_RSTA status_byte 1 UNT 0 399 return status_byte O 400 401 402 output a buffer to printer 403 amigo_write buffer length 404 char buffer 405 int length 406 407 int status dsj 0 408 409 write the buffer 410 HPIB_msg H_WRITE MTA DLA PR_SEC_DATA buffer length UNL 0 411 again 412 now wait for parallel poll response 413 if D...

Страница 192: ...TATUS Ox x n ptr_dev status 423 goto again 424 425 426 427 output error message and conditionally abort 428 fatal_err message fname flag 429 char message 430 char fname 431 432 fprintf stderr s Error s of s II procnam message fname 433 if errno perror IIII 434 else fprintf stderr n 435 436 if flag F_RTRN return 437 if flag F_EXIT exit 2 438 exit 3 439 0 12 OIL Programming Example ...

Страница 193: ...ing serial poll 3 48 example configuration 3 24 locking out local control 3 25 monitoring the SRQ line 3 31 parallel poll for device status 3 34 passing control to non active controller 3 49 remote control of devices 3 25 serial polling 3 46 servicing requests 3 31 setting up talkers and listeners 3 19 SRQ serial parallel poll service routine 3 33 transferring data 3 27 triggering devices 3 26 usi...

Страница 194: ...1 1 DIL programming example D 1 DIL routines E calling from Fortran 1 3 calling from Pascal 1 3 calling program structure 2 2 general purpose routines 2 3 HP IB DIL routines 3 2 linking 1 3 entity identifier 2 2 errno using 2 10 errno variable 2 10 error checking routines 2 10 errors while sending HP IB commands 3 16 example DIL programming D 1 F Fortran calls to DIL routines 1 3 G GO TO LOCAL 3 6...

Страница 195: ... control lines 1 13 general structure 1 9 handshake lines 1 10 HP IB I O buffered 3 72 HP IB I O buffered example 3 77 HP IB I O buffered locating errors in 3 79 HP IB I O operations combining 3 72 hpib_io 3 11 12 3 72 hpib_send_cmd 3 2 interface device file see interface special file 2 2 interface locking 2 14 interface special file 2 2 2 4 2 6 interfaces 1 5 interrupt hardware availability 2 27 ...

Страница 196: ...ce special file 3 13 P PARALLEL POLL CONFIGURE 3 6 PARALLEL POLL DISABLE 3 6 PARALLEL POLL ENABLE 3 6 Pascal calls to DIL routines 1 3 programming example DIL D l R read termination cause 2 20 2 24 read termination pattern removing 2 23 read termination pattern setting 2 15 read write to an interface 2 7 removing read termination pattern 2 23 resetting interfaces 2 13 S SELECTED DEVICE CLEAR 3 6 s...

Страница 197: ...r speed 2 15 special file 2 2 2 4 2 6 System Controller T determining if system controller 3 52 hpib_abort 3 54 hpib_ren_ctl 3 55 system controller duties 3 54 timeout setting 2 15 transfer speed setting 2 15 TRIGGER 3 5 U UNLISTEN 3 4 UNTALK 3 4 using errno 2 10 w write read to an interface 2 7 Index 5 ...

Страница 198: ......

Страница 199: ...creen control package that has many capabilities It is designed to efficiently utilize terminal screen control and display capabilities thus limiting its demand for computer CPU resources It can create and move windows and subwindows use display highlighting features and support other terminal capabilities that enhance visual interaction with display terminal users All interaction with a given ter...

Страница 200: ...ws can be created and dimensioned as programming needs dictate Such windows can be any size provided they do not exceed the row and or column capacity of the physical display screen When a program requires a window that is larger than the available display screen pads are used Pads have the same structure and characteristics as a window but they can be any size within the limits of reasonable memo...

Страница 201: ... a 16 bit character the remaining half is changed to a space character Insert character on a 16 bit character If the insert of a character starts from the right half of a 16 bit character the left half and the right half are changed to a space character Write a 16 bit character on the right boundary When a 16 bit character is added to the right margin a space character is added to the right margin...

Страница 202: ...t of a 16 bit character The change of the display enhancement is not done on the 16 bit character the change is done in character units not byte units When the change of display enhancement is done on a 16 bit character the change takes effect from the next character onward Applications Program Structure Consider the following example of an application program structure that uses curses include cu...

Страница 203: ...zes data structures and enables the clearok option in curses so that the screen is cleared during the first refresh operation in the program Upon completion of the first refresh operation the terminal screen is an exact replica of the text stored in the current screen data base Use of initscr 0 in a typical program is shown in the preceding sample program structure example When initialization is c...

Страница 204: ...e application program is finished certain clean up operations should be performed before termination While the amount of clean up needed varies depending on program structure and capabilities termination should always include a call to endwin O endwin 0 restores all terminal settings to their original state prior to program execution places the cursor at the bottom left corner of the screen and di...

Страница 205: ...d to as cursor optimization and is the basis for naming the curses package During the update operation curser is also changed to reflect the contents of the updated screen Keyboard Input curses capabilities include more than screen writing functions Several keyboard input functions are also supported including special handling of certain keys that normally generate a sequence of two or more charac...

Страница 206: ... option causes getch to return immediately with the value 1 if no input character is waiting This avoids program delays that would otherwise result when no response from the terminal is available getstr can be used to input an entire string of characters up to a newline instead of a single character It also handles echo erase and kill character functions associated with the input operation Example...

Страница 207: ... any sequence is absent from the table it cannot be converted so it is handled in unaltered form The following special keys are assigned the values and names indicated Some of the keys listed may not be supported on given terminals depending on the terminal model and its internal operating characteristics and whether the conversion sequence is in t erminfo Note Keypad character codes do not fit in...

Страница 208: ...ert Character or Enter Insert Mode key KEY_EIC 0514 Exit Insert character Mode Key KEY_CLEAR 0515 Clear Screen key KEY_EOS 0516 Clear to End of Screen key KEY_EOL 0517 Clear to End of line key KEY_SF 0520 Scroll Forward 1 Line KEY_SR 0521 Scroll Reverse backwards 1 line KEY_NPAGE 0522 Next Page key KEY_PPAGE 0523 Previous Page key KEY_STAB 0524 Set Tab key KEY_CTAB 0525 Clear Tab key KEY_CATAB 052...

Страница 209: ...sed use of IReturn Iis unnecessary noecho is used to prevent the character transmitted by the space bar from being echoed during refresh calls so that refresh operations are not adversely affected nonl is called to enable additional screen optimization idlok allows insert and delete line This capability helps streamline updates in some instances but produces undesirable effects in other cases Ther...

Страница 210: ...000000 Dim bit 27 A_DIM 001000000000 Bold bit 28 A_BOLD 002000000000 Invisible bit 29 A_REVERSE 004000000000 No print or display bit 30 A_PROTECT 010000000000 Alternate Character Set bit 31 A_ALTCHARSET 020000000000 addch and waddchr store window characters as 32 bit data words where the lower eight bits 0 7 of each word contain the character code and the upper sixteen bits 16 31 when set enable t...

Страница 211: ...ed To select a specific combination of attributes a program call to attrset or attron with new attribute values must precede text output to the window This can be used to enable one or more attributes when all were previously disabled disable all currently enabled attributes attrset O or change the current set to any other new current set To enable one or more attributes in the current set without...

Страница 212: ...d to select only one such as A_BOLD shown in the earlier example in this section or multiple attributes such as A_REVERSE and A_BLINK for blinking inverse video To change only one attribute or a certain combination of attributes while leaving the others undisturbed use attron 0 and attroff 0 The example program highlight at the end of this tutorial demonstrates typical use of attributes The progra...

Страница 213: ...ositions The name and octal value of each constant is also shown note that only eleven digits are needed to represent the 32 bit value the leading zero identifies the constant as a octal value First byte of a 16 bit character code bit 14 A_FIRSTOF2 000000040000 Second byte of a 16 bit character code bit 15 A_SECOF2 000000100000 These NLS attributes can be found in a 16 bit character not character ...

Страница 214: ...s only a data structure Use of more than one window does not imply the presence of more than one terminal nor does it involve more than one process A window is nothing more than a data object that can be copied to all or part of the terminal screen curses as presently implemented cannot handle windows that are larger than the available display screen use pads for such applications Pads Pads are da...

Страница 215: ...ernal window operations that are equivalent to refresh but which do not update the screen This is done by using a series of calls to wnoutrefresh or its equivalent for pads followed by a single doupdat e that copies the series of refreshes onto the physical screen in a single operation This is readily provided because refresh is really a call to wnoutrefresh followed by a call to doupdate To creat...

Страница 216: ...the original window to be fully restored to the screen eliminating the temporarily displayed window Examine the touchwin calls in window that precede refresh calls on overlapping windows touchwin calls prevent optimization by curses thus forcing wrefresh to completely overwrite the entire window area on the physical screen previously displayed data is thus erased in the window area only In some si...

Страница 217: ...r storage is completely independent of the original window it is associated with Because of shared character data structures curses does not allow deletion of any window delwin win or pad that has one or more undeleted subwindows If subwindows are created within a pad care must be exercised in the choice of correct refresh functions and other program characteristics to ensure correct data handling...

Страница 218: ...the name of the tty link and the type of terminal being used The notification program then goes to sleep until the master program finishes During termination the master program wakes up the notification program and all programs exit curses handles multiple terminals by always having a current terminal All function calls always pertain to the current terminal The master program should set up each t...

Страница 219: ...ent HP UX versions so it is necessary to busy wait or call sleep l between each check for keyboard input two waits one second between checks for available terminal keyboard characters two is only a simple example of two terminal curses It does not handle notification as described above instead it requires the name and type of the second terminal on the program procedure line As written two require...

Страница 220: ...nfo routines are preferred A program written at the t erminf0 level uses the framework shown here include curses h include term h Setupterm 0 1 0 putp clear_screen reset_shell_mode exit 0 The call to setupterm handles initialization setupterm O l O invokes reasonable defaults If setupterm cannot determine the terminal type it prints an error message and exits The calling program should call reset_...

Страница 221: ...ity to be output affcnt is the number of lines affected by the output for example insert_line may have to copy all lines below the current line and may require time proportional to the number of lines being copied By convention affcnt is 1 if no lines are affected rather than 0 because affcnt is multiplied by the amount of time required per item and a zero time may be undesirable outc is the name ...

Страница 222: ...and deleting characters and lines The command interpreter accepts not only ASCII characters but also special non typing keys This is important a good program accepts both Defining the keyboard so that every special key has its function defined on a normal typing key as well provides a desirable increase in flexibility The benefit for new users for example is that they can use arrow keys without ha...

Страница 223: ... sound of the bell is objectionable or distracting Still there may be instances where an audible signal is still needed for certain purposes even in quiet environments In such cases the beep 0 routine can still be called instead whenever a real beep is preferred If beep is called and the terminal is not equipped to process the call curses substitutes the flash in its place if possible and vice ver...

Страница 224: ...antage is the inevitable delay from the time a key is pressed until it can be processed by the program when an escape key is pressed possibly even accidentally Many existing programs use escape as a fundamental command which often cannot be changed without incurring the wrath of a large group of users Such programs cannot make use of special keys without dealing with the aforementioned ambiguity a...

Страница 225: ...nd 0 respectively Two additional constants are defined the values returned by most curses routines OK is returned when the routine was able to successfully complete its assigned task ERR indicates that an error occurred such as an attempt to place the cursor outside a defined window boundary or create a window larger than the physical screen thus the task was not successfully completed The include...

Страница 226: ...ring operation newterm should be used for each terminal instead of the single call to initscr newterm returns a variable of type SCREEN which should be saved and used each time that terminal is referenced Two file descriptors must be present one for input and one for output Use endwin for each terminal prior to program termination to restore previous terminal states and dismantle data structures t...

Страница 227: ...ting with the data can only pass 7 bit characters This feature is useful for applications where an extended non text character set is needed and the terminal has a meta shift key available Curses takes whatever measures are needed to handle the 8 bit input including the use of raw mode if necessary In most cases the character size is set to 8 parity checking disabled and 8th bit stripping is disab...

Страница 228: ...a given window If this option and scrollok are both active the scrolling region is scrolled up one line and refresh is called to update the screen whenever the cursor position is moved beyond the lower limit of the scrolling region in the window To get a scrolling effect on the terminal screen idlok must also be enabled Terminal Configuration Routines These routines are used to set or disable vari...

Страница 229: ...stores the terminal to the state that was obtained by the last previous call to savetty Window Manipulation Routines Window manipulation routines are used to create move and delete windows subwindows and pads and perform certain other operations newwin newpad and subwin create new structures delwin deletes window pad and subwindow structures and mvwin relocates a window to a different area within ...

Страница 230: ...terminal display are handled by pad and window refresh update functions refresh 0 and wrefresh win transfer the contents of the default or specified window to the current screen window and to the terminal display doupdate 0 and wnoutrefresh win are used to accumulate several window copy operations to the standard screen window by using multiple calls to wnoutrefresh win then transferring the curre...

Страница 231: ...ion after the placement is determined by the type of character written addstr str and related functions place the specified string in the selected window mv prefixed to the base function name causes the current cursor character position to be changed to the specified YJ X location before the string is placed Cursor position after the placement is determined by the characters contained in the writt...

Страница 232: ... handled by addch which places the formatted data in the window Miscellaneous Window Operations scrollw win is used to scroll a given window up one line each time the function is called box win vert hor uses the specified characters to draw a box around the specified window When the window is boxed the top and bottom rows and left and right columns in the window are no longer available for normal ...

Страница 233: ... buffer used by getstr If echo is enabled the string is also placed in the associated window but only the characters stored in the buffer are used by scanw When scanning is complete the processed results string results are placed in the specified args variables Video Highlighting Attribute Routines Each character written into a window is stored as a 32 bit word The lower eight bits contain the cha...

Страница 234: ...as well Attribute functions and arguments must be logically conceived For example attron A_NORMAL and attroff A_NORMAL though executable do nothing because all bits in A_NORMAL are cleared value is zero The bit level logical OR of attron has no effect all bits zero and attroff is ineffectual because A_NORMAL is inverted all bits set to 1 before a bit level logical AND is used to clear the selected...

Страница 235: ...ts this function and the related program structure must be handled carefully to ensure proper termination of program processes before the program exits Delay Functions Delay functions are not highly portable but are frequently needed by programs that use curses especially real time interactive response programs Use of these functions should be avoided where possible draino ms is used to reduce the...

Страница 236: ......

Страница 237: ...ts the following functions Those marked with an asterisk are also supported by mini curses some unmarked routines might work but are not officially supported by mini curses Proceed at your own risk if you try them Curses Routines 2 1 ...

Страница 238: ...t args mvwaddch win y x ch mvwaddstr win y x str 2 2 Curses Routines getchO getstr str gettmode getyx win y x has_icO has_ilO idlok win boolean_flag inch initscrO insch e insertlnO intrflush win boolean_flag keypad win boolean_flag killcharO leaveok win boolean_flag longnameO meta win boolean_flag move y x mvaddch y x ch mvaddstr y x str mvcur oldrow oldeol newrow neweol mvdelch y x mvgetch y x mv...

Страница 239: ...xcol printw fmt args raw 0 refreshO resetterm 0 resettyO savetermO savettyO scanw jmt args scroll win scrollok win boolean_flag standend standoutO subwin orig_ win n_lines n_ eols beg_y beg_x touchwin win traceoffO traceonO typeahead jd unctrl eh waddch w n ch waddstr win str wattroff win attrs wattron win attrs wattrset w n attrs wclear w n wclrtobot win wclrtoeol w n wdelch wz n c wdeleteln win ...

Страница 240: ...indow stdscr Programs that use the curses package are subject to the normal rules of C compiler statement syntax Routines are listed alphabetically by function keyword which is printed in slanted bold type When two or more functions are related to a common keyword the root keyword is listed in bold followed by a list of related function names in normal italics The individual related functions are ...

Страница 241: ...ent attributes are all zero disabled by performing an equivalent bit level logical OR operation between the 7 bit character code in bit positions 0 through 6 and selected video attribute bits in bit positions 7 through 15 to create a single 16 bit integer representing the character and its associated highlighting attributes If no highlighting attributes for the window are currently active any attr...

Страница 242: ...A_STANDOUT A_UNDERLINE A_REVERSE A_BLINK A_DIM A_BOLD A_INVIS invisible A_PROTECT and A_ALTCHARSET Enables the specified video highlighting attributes without affecting other attributes Any or all of the following attributes can be specified multiple attributes must be separated by the C logical OR operator I which performs a bit level logical OR on all attributes specified in the function call A_...

Страница 243: ...dow space is reduced by two lines and columns when a box is present These functions place the terminal in and out of CBREAK mode respectively When cbreak character mode operation is active each typed character is immediately available to the program If disabled nocbreak the tty driver holds characters until a newline character is received then releases the entire line to the program line mode oper...

Страница 244: ...t section of this chapter The character at the present cursor position is deleted All remaining characters on the line to the right of the deleted character are moved left one position Other lines are not disturbed The operation is performed only on the window and does not use the terminal hardware delete character feature because no terminal operation has been performed The present cursor line is...

Страница 245: ... the output queue has been reduced sufficiently drained so that the remaining characters can be transmitted in not more than ms milliseconds For example draino 50 at 1200 baud would suspend program execution until no more than 6 characters remain to be sent 6 characters 1200 baud require about 50 ms transmit time This routine is used to keep the program and thus the keyboard from getting ahead of ...

Страница 246: ...r s chosen erase character from the terminfo data base The returned character should be interpreted by the program as an erase previous character command whenever it is received from the terminal Restores the current terminal to the state it was in prior to the most recent call to resettermO State information stored by the most recent previous call to saveterm0 provides the needed restoration info...

Страница 247: ...dch is followed immediately by a call to wrefresh which updates the terminal screen with the echo character If an escape character is received special timeouts are set up to determine whether the character is part of a multiple character keypad sequence See Use of Escape in Program Control topic earlier in this tutorial for a detailed discussion of how escape is handled If meta is enabled and the ...

Страница 248: ...er until a newline is received then they are made available to the program nocbreak This routine is used to input an entire line from the terminal It is equivalent to getch except that it handles an entire string instead of single characters Handling of each character is identical to getch except that text and meta characters are packed into the string variable str instead of being returned to the...

Страница 249: ...disabled curses does not use the capability Use only when the program requires it such as a screen editor idlok is disabled by default because it tends to be annoying when used in applications where it is not really needed If insert delete line cannot be used curses redraws changed portions of all lines that do not match the desired result Returns the character located at the current or specified ...

Страница 250: ...f it cannot fit inside the window This is a window operation that does not interact with the terminal so no hardware insert line feature is used Causes tty driver queue to be flushed on interrupt When enabled an interrupt quit or suspend keypress from the terminal flushes all output from the tty driver queue providing a faster response to the interrupt However curses loses its record of what is cu...

Страница 251: ...eok is set TRUE for a given window it remains active for the duration of the program or until another call sets it FALSE Returns a pointer to a static area containing a verbose description of the current terminal This static area is defined only after a call to initscr newterm or setupterm meta win boolean_flag When enabled text characters are returned by getch as 8 bit character codes masked by o...

Страница 252: ...neweol The user program is expected to keep track of the current cursor position Unless a full screen image is kept curses must make pessimistic assumptions that sometimes result in less than optimal cursor motion For example if the cursor needs to be moved a few spaces to the right the task could be accomplished by retransmitting the characters between the present and the desired position but if ...

Страница 253: ... args See scanw fmt args Suspends program operation for ms milliseconds napms is similar to sleep but has higher resolution The resolution actually provided depends on the resolution of available operating system facilities If a resolution of at least 0 100 sec is not available the routine rounds to the next higher second calls sleep and returns ERR Otherwise the value OK is returned Creates a new...

Страница 254: ...d row and column of the physical screen and return a window pointer the upper left hand corner of the physical screen is row 0 column 0 If the number of lines and or columns is specified as zero the default value LINES minus beg_y and COLS minus beg_x is used instead A screen buffer for the window is also created To create a new full screen window use newwin 0 0 0 0 Defines handling of newline cha...

Страница 255: ...he pad and screen are to be used pminrow and pmincol identify the upper left corner of the pad area to be displayed sminrow smincol smaxrow and smaxcol define the display boundaries on the physical screen The lower right hand corner of the pad area being displayed is calculated from the screen boundary parameters because both rectangles must be the same size Both rectangles must lie completely wit...

Страница 256: ...curses was started The current curses state is saved by savetermO for possible future use by fixtermO resetterm and fixterm should be used in all shell escapes Equivalent routines are also available at the t erminf0 level Restores resets the tty modes to those stored in the buffer by the last previous savettyO command This means that only one set of states can be stored at any given time See savet...

Страница 257: ...n the window and terminal are scrolled up one line idlok must also be called before a physical scrolling effect can be produced on the terminal screen Sets up a software scrolling area in window win or stdscr t and b are the top and bottom lines of the scrolling region line 0 is the top line of the window If this option and scrollok are both enabled an attempt to move off the bottom margin causes ...

Страница 258: ... not alter other attributes in effect at the time standout applies to the default window stdscr wstandout affects the specified window Creates a new window containing the specified number of lines and columns within existing window orig_win beg_y and beg_x specify the starting row and column position of the window on the physical screen not relative to window orig_win The subwindow uses that part ...

Страница 259: ...iptor for typeahead check fd is an integer obtained from open or fileno Setting typeahead to 1 disables typeahead check Default file descriptor is o standard input Typeahead is checked independently for each screen for multiple interactive terminals it should be set to the appropriate input for each screen A call to typeahead always affects only the current screen Converts the character code repre...

Страница 260: ...outrefresh win wprintw win mt args wrefresh win wscanw win mt args wsetscrreg win t b wstandend win wstandout win 2 24 Curses Routines See deleteln 0 See eraseO See getchO See getstr str See inch See insch c See insertlnO See move y x See doupdate 0 See printw jmt args See refresh o See also doupdate 0 See scanw jmt args See setscrreg t b See standendO See standout 0 ...

Страница 261: ...Initializes the specified terminal term is the character string representing the name or model of the terminal filenum is the HP UX file descriptor of the terminal being used for output errret is a pointer to the integer in which a success failure indication is returned The values returned can be 1 initialize complete 1 terminf database not found or 0 no such terminal If 0 is given as the value of...

Страница 262: ... ttytype an array of characters to the value of the list of names for the terminal in question The list is obtained from the begining of the terminfo description Upon completion of setupterm the global variable cur_term points to the current structure of terminal capabilities A program can use two or more terminals at once by calling setupterm for each terminal and saving and restoring cur_term nl...

Страница 263: ...es affcnt is used to determine the number of padding characters that must be created in the output string to produce the required delay s based on known terminal characteristics obtained from the terminal identification data base Transmits the appropriate string to stdout to activate the specified video attributes which can include any or all of the following A_STANDOUT A_UNDERLINE A_REVERSE A_BLI...

Страница 264: ... future releases of HP UX Description of Termcap Compatibility Routines tgetent bp name tgetflag id tgetnum id tgetstr id area tgoto cap col row tputs cap affcnt n 2 28 Curses Routines Obtains and returns with termcap entry for name Returns the boolean entry for id Returns the numeric entry for id Returns the string entry for id and places the result in area Attaches col and row parameters to the ...

Страница 265: ...ne idlok stdscr TRUE has been called to enable the capability By default insert delete line during refresh is disabled FALSE not for performance reasons there is no speed penalty involved but because experience has shown that not only is insert delete line frequently not needed especially in simple programs it can sometimes be visually annoying when used by curses Insert delete character is always...

Страница 266: ...havior The term magic cookie means that changes in highlighting are controlled by storing a magic cookie character in a location on the screen While this cookie takes up a space preventing an exact implementation of what the programmer wanted curses takes the extra character space into account and moves part of the line to the right when necessary In some cases this unavoidably results in losing t...

Страница 267: ...l environment When the program is ready to terminate each terminal should be selected in turn by a call to set_term then cleaned up with screen clearing and cursor locating routines followed by a call to endwin for that terminal Repeat the sequence for each additional terminal used by the program The example program TWO demonstrates the technique Video Highlighting Video highlighting attributes ca...

Страница 268: ...e window The variable is formed by using one of the following routines attrset attrs attron attrs attroff attrs standout 0 standendO wattrset win attrs wattron win attrs wattroff win attrs wstandout win wstandend win The following attributes can be specified in the attrs argument for corresponding attribute set on off routines A_STANDOUT A_UNDERLINE A_REVERSE A_BLINK A_DIM A_BOLD A_INVIS A_PROTECT...

Страница 269: ...e previous set of current attributes is destroyed If attron or wattron was called the routine performs a logical OR of the current attributes with the new attributes then places the result in the current attributes variable and returns The revised current attributes variable contains all previously active attributes plus the new attributes If attroff or wattroff was called the routine inverts the ...

Страница 270: ...ed as an attribute argument for attrset to restore normal text display attrset O is easier to type but less descriptive Both are equivalent A_ATTRIBUTES has the octal value 037740000000 It can be logically ANDed with a character data word to isolate the attribute bits and discard the character A_CHARTEXT has the octal value 000000000377 It can be logically ANDed with a character data word to isola...

Страница 271: ...ing region that is normally set to include the entire window curses contains a routine that can be used to change the scrolling region to any location in the window by specifying the top and bottom margin lines The routines are called by setscrreg top bottom for the stdscr window or wsetscrreg win top bottom for other windows When the cursor advances beyond the bottom line in the region all lines ...

Страница 272: ...ined calls is produced by the compiler at compile time mini curses routines are limited to commands that deal with the stdscr window Certain other high level functions that are convenient but not essential such as scanw printw and getch are not available as well as all commands that begin with w Low level routines such as hardware insert delete line and video attributes are supported as are mode s...

Страница 273: ...fo level Typeahead Check When a user types something during a screen update the update stops pending a future update This is useful when several keys are pressed in sequence each of which produces a large amount of output For example in a screen editor the forward screen or next page key draws the next screenful of text If the key is pressed several times in rapid succession rather than drawing se...

Страница 274: ...in no delay mode When nodelay is active any call to getch returns the value 1 if there is nothing available for immediate input This feature is helpful for real time situations where a user is watching terminal screen outputs and presses a key when he wants to respond For example a program can be producing a text pattern on the screen while maintaining an open opportunity for the user to press cer...

Страница 275: ...ne register int row 0 col 0 register char c int long char initscrO char_count 0 count non blank characters t buf BUFSIZ for row 0 row MAXLINES row screen array initialize for col 0 col MAXCOLS col row 0 col 0 s row col Read screen in while c getchar EOF row LINES if c n col COLS Place char in screen array s row col c else if c col 0 row char_count time t Seed the random number generator srand int ...

Страница 276: ... row rand LINES col rand 2 caLS if s row col s row col EaF move row col addch s row col s row col EaF char_count refreshO endwin exit 0 3 12 Program Operation ...

Страница 277: ...FILE fd char linebuf BUFSIZ int line void done perror exit if argc 2 fprintf stderr usage Is file n argv O exit 1 if fd fopen argv l r NULL perror argv l exit 2 signal SIGINT done initscrO noechoO cbreakO nonlO enable more screen optimization idlok stdscr TRUE allow insert delete line while 1 move O O for line 0 line LINES line if fgets linebuf sizeof linebuf fd NULL clrtobotO done 0 move line O p...

Страница 278: ... doneO refreshO if getch q done 0 void move LINES l 0 clrtoeolO refreshO endwinO exit O 3 14 Program Operation ...

Страница 279: ...hlighting and N restores normal display characteristics include curses h main argc argv char argv FILE fd int c c2 if argc 2 fprintf stderr Usage highlight file n exit 1 fd fopen argv 1 r if fd NULL perror argv l exit 2 initscrO scrollok stdscr TRUE for c getc fd if c EOF break if c c2 getc fd switch c2 case B attrset A_BOLD continue case U attrset A_UNDERLINE continue case N Program Operation 3 1...

Страница 280: ... else fclose fd refreshO endwinO exit O 3 16 Program Operation attrset O continue addch c addch c2 addch c ...

Страница 281: ...LINES i top 3 lines mvprintw i O This is line Y d of stdscr i for refreshO c getchO switch c case c Enter command from keyboard werase cmdwin clear window wprintw cmdwin Enter command wmove cmdwin 2 O for i O i COLS i waddch cmdwin wmove cmdwin 1 O touchwin cmdwin wrefresh cmdwin wgetstr cmdwin buf touchwin stdscr The command is now in buf It should be processed here erase 0 Program Operation 3 17...

Страница 282: ...for i O i LINES i mvprintw i O II sll buf refreshO break case q endwin exit O 3 18 Program Operation ...

Страница 283: ...y otherttytype inputfile n exit 1 fd fopen argv 3 r fdyou fopen argv 1 W signal SIGINT done die gracefully me newterm getenv ITERM stdout stdin initialize my tty you newterm argv 2 fdyou fdyou Initialize his her terminal set_term me noechoO cbreakO nonlO nodelay stdscr TRUE set_term you noechoO cbreakO nonlO nodelay stdscr TRUE Set modes for my terminal turn off tty echo enter cbreak mode Allow li...

Страница 284: ...ump_page me set_term you c getchO if c q wait for user to read it done 0 if c dump_page you sleep l dump_page term struct screen term int line set_term term move O O for line O line LINES l line if fgets linebuf sizeof linebuf fd NULL clrtobotO done 0 mvprintw line O s linebuf standout 0 mvprintw LINES l O More standend refresh sync screen 3 20 Program Operation ...

Страница 285: ...minal 1 1 1 1 1 to lower left corner 1 clear bottom line 1 flush out everything 1 curses clean up 1 1 Clean up second terminal 1 set_term me move LINES i 0 clrtoeolO refresh endwin exit O 1 to lower left corner 1 1 clear bottom line 1 1 flush out everything 1 1 curses clean up 1 Program Operation 3 21 ...

Страница 286: ... h int ulmode 0 Currently underlining main argc argv char argv FILE fd int c c2 int outchO if argc 2 fprintf stderr Usage termhl file n exit 1 if argc 2 fd fopen argv 1 r if fd NULL perror argv 1 exit 2 else fd stdin setupterm O 1 0 for c getc fd if c EOF break if c c2 getc fd switch c2 case B tputs enter_bold_mode 1 outch continue 3 22 Program Operation ...

Страница 287: ...de l outch ulmode 0 continue putch c putch c2 putch c 1 This function is like putchar but it checks for underlining 1 putch c int c outch c if ulmode underline_char outch b tputs underline_char l outch Outchar is a function version of putchar that can be passed to tputs as a routine to call 1 outcb c int c putchar c Program Operation 3 23 ...

Страница 288: ...lude curses h define CTRL c c 037 main argc argv char argv int i n l int c FILE fd if argc 2 fprintf stderr Usage edit file n exit l fd fopen argv l r if fd NULL perror argv l exit 2 initscrO cbreakO nonlO noechoO idlok stdscr TRUE keypad stdscr TRUE Read in the file while c getc fd EOF addch c fclose fd move O O refreshO editO Write out the file fd fopen argv l W 3 24 Program Operation ...

Страница 289: ...inelen 0 mvinch lineno linelen linelen return linelen 1 Global value of current cursor position int row col edit 0 int c for move row col refreshO c getchO switch c Editor commands hjkl and arrow keys move cursor in direction indicated case h case KEY_LEFT if col 0 col break case j case KEY_DOWN if row LINES 1 row break Program Operation 3 25 ...

Страница 290: ... break 1 x delete current character 1 case KEY_DC case x delchO break 1 0 open up a new line and enter input mode 1 case KEY_IL case 0 move row col O insertlnO input 0 break 1 d delete current line 1 case KEY_DL case d deletelnO break 1 L redraw screen 1 case KEY_CLEAR case CTRL L 3 26 Program Operation clearok curscr refreshO break ...

Страница 291: ... Insert mode accept characters and insert them End with D or EIC input 0 int c standout 0 mvaddstr LINES 1 COLS 20 INPUT MODE standend move row col refreshO for c getchO if c CTRL D I I c break insch c move row col refreshO move LINES 1 COLS 20 clrtoeolO move row col refresh Program Operation 3 27 ...

Страница 292: ......

Страница 293: ... attributes 1 12 attroff 1 13 1 35 2 6 3 6 attron 1 13 1 35 2 6 3 6 attrset 1 2 1 12 13 2 6 3 6 B baudrate 1 36 2 7 beep 1 25 1 36 2 7 blinking highlight 1 12 bold highlight 1 12 box 1 34 2 7 C cbreak 1 5 1 11 1 30 2 7 clear 1 32 2 7 clearok 1 5 1 28 2 8 clrtobot 1 7 1 11 1 32 2 8 clrtoeol 1 11 1 32 2 8 COLS 1 6 configuration routines 1 30 creating windows 1 17 current attributes 1 13 Index 1 ...

Страница 294: ...elay_output 2 25 delch 1 33 2 8 deleteln 1 33 2 8 deleting text 1 33 deleting text from windows 1 33 deLterm 2 8 delwin 2 8 dim highlight 1 12 display highlighting 1 12 doupdate 1 32 2 9 draino 1 37 2 9 E echo 1 30 2 9 endwin 1 6 1 28 2 10 3 9 environment variable TERM 1 1 erase 1 32 2 10 erasechar 1 36 2 10 escape sequences 1 25 escape used in program control 1 25 example programs editor 1 24 3 2...

Страница 295: ...t escape sequences 1 14 highlighting attribute routines 1 35 highlighting data structure 1 2 highlighting displays 1 12 highlighting program operation 3 3 idlok 1 5 1 11 1 28 2 13 inch 1 34 2 13 include files 1 27 initialization routines 1 28 initscr 1 5 1 28 2 13 input routines 1 34 insch 1 33 2 14 insert delete line program operation 3 1 inserting text 1 33 inserting text in windows 1 33 insertl...

Страница 296: ... usage 1 21 M magic cookie 3 2 manipulation routines 1 31 meta 1 28 2 15 mini curses 1 27 3 8 mini curses routines list of 2 1 miscellaneous curses functions 1 36 miscellaneous window operations 1 34 move 1 32 2 16 multipe types of termianls dealing with 3 2 multiple terminals 1 19 3 2 multiple terminals program operation 3 2 multiple windows 1 16 mvaddch 2 16 mvaddstr 2 16 mvcur 2 16 mvdelch 2 16...

Страница 297: ...ributes 1 15 NLS environment 1 3 nocbreak 2 18 nodelay 1 28 2 18 nodelay mode 3 10 noecho 1 11 1 30 2 18 nonl 1 11 1 30 2 18 no print highlight 1 12 noraw 1 31 2 18 o OK 1 27 option setting routines 1 28 options 1 28 output data structure 1 2 overlay 1 17 1 31 2 19 overwrite 1 17 1 31 2 19 p padding 1 2 pads 1 16 placing text in windows 1 32 pnoutrefresh 1 32 2 19 portability functions 1 36 prefre...

Страница 298: ...e 1 6 2 22 scroll 2 21 scrolling regions in window or pad 3 7 scrollok 1 30 2 21 scrollw 1 34 set_curterm 2 22 setscrreg 1 30 2 21 3 7 set_term 1 20 2 22 setterm 2 21 setupterm 1 22 1 28 2 21 2 25 special keys on terminals keypad program handling 3 6 standard screen 1 2 standend 1 36 2 22 3 6 standout 1 36 2 22 3 6 standout highlight 1 12 stdscr 1 2 struct screen 3 2 structure considerations for p...

Страница 299: ...sted description of 2 25 text data structure 1 2 touchwin 1 18 1 31 2 23 tparm 2 25 tputs 1 23 2 27 traceoff 2 23 traceon 2 23 tty mode function 3 9 typeahead check 1 28 2 23 3 9 U unctrl 2 23 underlining highlight 1 12 using multiple windows 1 17 V vidattr 1 23 2 27 video highlighting attribute routines 1 35 video highlighting program operation 3 3 vidputs 2 27 W waddch 1 12 1 17 2 23 wattroff 1 ...

Страница 300: ...o 1 34 inserting and deleting text 1 33 miscellaneous operations 1 34 multiple 1 16 placing text in windows 1 32 subwindows 1 19 window manipulation routines 1 31 window writing routines 1 32 winsertln 2 24 wmove 1 32 2 24 wnoutrefresh 1 32 2 24 wprintw 2 24 wrefresh 1 17 1 32 2 24 wscanw 2 24 wsetscrreg 2 24 3 7 wstandend 2 24 wstandout 2 24 3 6 Index 8 ...

Страница 301: ......

Страница 302: ......

Страница 303: ...ibutes Multiple Windows Pads Creating Windows Using Multiple Windows Subwindows Multiple Terminals Low Level Terminfo Usage A Larger Example Use of Escape in Program Control Program Routines Program Structure Considerations Terminal Initialization Routines Option Setting Routines Terminal Configuration Routines Window Manipulation Routines Terminal Data Output Routines 1 1 1 2 1 2 1 2 1 3 1 4 1 7 ...

Страница 304: ...ines Termcap Compatibility Routines 3 Program Operation Insert Delete Line Additional Terminals Multiple Terminals Video Highlighting Special Keys Scrolling Regions Mini Curses TTY Mode Functions Typeahead Check getstr Routine longname Nodelay Mode Example Programs SCATTER Example Program SHOW Example Program HIGHLIGHT Example Program WINDOW Example Program TWO Example Program TERMHL Example Progr...

Страница 305: ......

Страница 306: ...HP Part Number 97089 90057 Microfiche No 97089 99057 Printed in U S A E0989 Flin HEWLETT PACKARD 97089 90660 For Internal Use Only ...

Отзывы: