Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 11 of 16

4985 Network Controller Programmer's Guide: Section 6: Writing the Host Program

Pages 81 to 94 of 130, from 4985 Network Controller Programmer's Guide

The original document is the PDF (762 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

Filed in the catalog under the Norand Route Commander 4000 Series APU

Page 81

Section 6 Writing the Host Program "

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

The communications controller offers several options designed to provide flexible options for reading records from the communications con troller. "

"

"

"

"

You can add an end-of-record delimiter to the end of each record. The default delimiter is a carriage return. You can configure the communications controller to pad all records to a fixed-block size. The host sets the pad character. The default is an ASCII space. The host-ready character, a question mark by default, can change to any other character, such as an XON character. The upload data record data portion may contain transparent data if the port configures for transparent mode with EBCDIC hosts. All other data sent to the host is character data. The network communications controller reads the initialization record as 8-bit data, no parity, and one-stop bit, so that the host can set the parity for the host-communications controller connection in the initialization record.

If the host is reading transparent data from the communications controller, then the host cannot read to an end-of-record delimiter. You could solve this problem by padding all records to a fixed length. Yet, this is inefficient as extra length would be added to download requests. As an alternative, the system reads the channel ID and record type portion of each record before the rest of the record. The host could then use a table, indexed by record type, to determine the number of bytes to read for the record. 4985 Network Controller Programmer’s Guide

6-1

Page 82

SECTION 6

" NOTE:

"

Writing the Host Program

The system sends the asterisk before the initialization record or when the controller expects a question mark to reset the controller.

The purpose of this section is to help you write a host communications program. The pseudo-coded host program acts as a guide to writing your own program. There are many ways to write a computer program. Each method has its advantages depending on the programming language used. Host computers may have different operating systems, device names and assignments, or linkages. Norand provides a generic pseudo-coded host program that includes most everything you need to know for your host computer to communicate with the 4985 Network Controller. " NOTE:

The pseudo programs in the following subsections do not have a status screen. They do not send blank initialization and activation records to the controllers. The program does run until a communication error occurs. You must thoroughly test all code before including it in your system.

" NOTE:

For the latest “C” programs available on BBS, call (319) 369-3515.

Starting the Main Routine The main routine is a top-level routine directing the flow of the program. Physically, this routine determines if a controller is trying to communicate with it, reads a record, checks parameters, and depending on record type, performs or calls a subroutine to do the real work. When done reading records, it closes the files and ends. There are several subroutines that check errors and parameter. If errors appear, or a field’s contents are invalid, the program outputs a message to a log file or a display. EXAMPLE:

Pseudo-code program Main Routine

Main Routine Open Files Initialize counters to 0 and port/channel states to inactive. Send Initialization Record to controller. 6-2

4985 Network Controller Programmer’s Guide

Page 83

SECTION 6

"

Writing the Host Program

While Not Finished Send the ready character. Perform Controller_Read Decode (channel) and Record (type) If type is Upload_Data Perform Received_Upload_Data_Routine Else if type is End_Tcom_Status Perform End_Status_Routine Else if type is Download_Data_Request Perform Download_Data_Routine Else if type is Inactive_Status Update host display “port inactive” Else if type is Active_Status Update host display “port active” Else if type is Activate_Request Perform Activation_Routine Else if type is Special_Request Perform File_Processing_Routine Else if type is Directive_Status Perform Directive_Status_Routine Else Perform Invalid_Record_Routine Endif End While Not Finished Close Files End Program End Main Routine 4985 Network Controller Programmer’s Guide

6-3

Page 84

SECTION 6

"

Writing the Host Program

Receiving Data The controller-to-host record type read was an Upload Data Record. This means a HHC on the controller’s LAN is sending upload data to the host computer. You need to: 1. 2. 3.

Determine which channel receives the data. Ensure that the received data writes to the proper receive file. Send a “READY” command to indicate to the controller to send the next data block. You return to the Main Routine to read the next record from the controller. The following example is a simplified version of the communication session using a three-channel LAN. EXAMPLE:

File processing session Host

Controller

1. Get initialization parms for device Send Init “2 -S0/”

-------->

(do not wait for response) “?” (ready)

--------> first HHC begins to transmit

<-------

Chan 1 Upload Data

Set up data save area for channel 1 “?” (ready)

--------> second HHC begins to transmit <--------

Chan 7 Upload Data

Set up data save area for channel 7 “?” (ready)

-------->

<-------- second HHC transmits another block of data Chan 7 Upload Data

Add record to data save area already set up “?” (ready)

---------> third HHC begins to transmit <--------

Set up data save area for channel 4 “?” (ready) 6-4

4985 Network Controller Programmer’s Guide

-------->

Chan 4 Upload Data

Page 85

SECTION 6

Host

Writing the Host Program

Controller

<-------EXAMPLE:

" second HHC transmits another block of data Chan 7 Upload Data

Pseudo-code program Upload Data Routine

Upload Data Routine If channel is inactive Save HHC ID from first upload record in save area for channel Reset upload sequence counter for channel. Change channel state for channel to “uploading.” Write upload record with channel/HHC ID/sequence counter key. Else Increment upload sequence counter. Write upload record with channel/HHC ID/sequence counter key. Endif End Upload_Data Routine

Download Data The HHC sends a download data request through the controller to the host computer. The host program needs to send a download data record, an end-of-data record, or a download file directive in return. EXAMPLE:

Pseudo-coded Download Data routine

Download Data Routine If channel state is uploading log good status for upload reset download sequence counters for channel change channel state to downloading 4985 Network Controller Programmer’s Guide

6-5

Page 86

SECTION 6

"

Writing the Host Program

Endif If there is more download data for the HHC send download data record Else send an end-of-data record Endif Return End Download_Data_Routine " NOTE:

One way to associate download data with an HHC is to maintain a download request file which contains a list of download files for each scheduled HHC. The list of files may actually be a list of keys for indexed file systems.

Ending Status Routine When the host receives this record, the record indicates that an HHC has terminated its communications session. The session information must be recorded in a log file. The log file is helpful when starting out, as it allows you to debug your code faster. EXAMPLE:

Pseudo-coded program Ending Status Routine

End Status Routine: Initialize log record. Move “END” to log record type Move the session key (channel, HHC ID) to log record key. Move Upload_count to log record upload counter. Move Download_count to log record download counter. Move current_status to log record status. Add the log record to the upload status. Change session status to inactive. Display log status of HHC telecom session. 6-6

4985 Network Controller Programmer’s Guide

Page 87

SECTION 6

"

Writing the Host Program

/* close and reopen the upload file to flush the buffers to disk */ Perform Upload_flush. /* write the log record */ Write log_rec to the log file. Close the log file. Reset the channel status to inactive. Return. End End_Status_Routine.

Handling Time-Fill Records The controller periodically sends either an Inactive Status Record (record type “3”) or an Active Status Record (record type “4”). These records indicate the logical port’s current status, and are sent whenever the controller is idle. The idle period could occur during a telecom session with an HHC as it switches from upload to download mode, or, when the controller is waiting for the next HHC to begin its telecommunications. When the host program receives the Inactive or Active status record, it should possibly update a status display or write status information to a log file. These records primarily tell the host program that the controller is still alive, and should not be disconnected through an automatic timeout.

Activating LAN Port The host program activates the LAN port in response to active request records. The controller sends requests for the port whenever it disconnects. The prior connection status for this port is contained in the uploaded activate request record. The host program should respond with either an activate auto-answer record (record type 3) or an activate auto-dial record (record type 4). 4985 Network Controller Programmer’s Guide

6-7

Page 88

SECTION 6

"

Writing the Host Program

Processing Special Requests Special request records combine a variety of special records into one record type. Currently only one subtype is defined: File Request. File requests obtain file processing information from the host. The host responds to this record with either a file directive or an end-of-data record to return to normal data communications. See pages 5-8 through 5-10 for sample host-to-controller communications sessions.

Processing Directive Status Records The controller sends a directive status record to the host after completing a host directive. Check this record for a good read before sending the next record, or for an error status. You may wish to set up a different routine for handling each error type returned. Valid status responses for file processing directives returned from the controller are detailed on page 4-19.

Adapting Older Host Programs Host programs designed to run with an NI311 require minimal changes, as specified below, to communicate with the controllers running in a compatibility mode. The required changes generally fall into the following categories: "

"

"

Record Types: the controller adds a number of new record types and the function of some of the old NI311 record types has changed. Logical Channels: The controller may have up to three logical channels per physical port. New Enhancements: The controller provides a number of new enhancements which may be enabled when the host is ready to support them.

The other major area of change is in the data record. The length of the data block has increased from 128 bytes to 256 bytes. 6-8

4985 Network Controller Programmer’s Guide

Page 89

SECTION 6

"

Writing the Host Program

Record Types Record types for both the NI311 and controllers follow. Listed are differences (if any) in how you can use the records.

NI311 Record Types NI311-to-Host a) 0 Upload Data b) 1 End-of-call Status c) 2 Data Request Host-to-NI311 a) 0 Download Data b) 1 End-of-data c) 2 Initialization d) 3 Cancel auto-dial f)

5 Deactivate auto-dial for one minute.

4985 Network Controller The length of the data block has increased from 128 bytes to 256 bytes. Controller-to-Host a) 0 Upload Data b) 1 End-of-session Status After each HHC completes the communication session, the system sends end-of-session records to indicate the status of a single HHC session. This differs from the NI311 end-of-call record that provides the status after the system loses a port connection. c) 2 Data Request 4985 Network Controller Programmer’s Guide

6-9

Page 90

SECTION 6

"

Writing the Host Program d) 3 Inactive Status The system sends inactive status records to the host whenever a period of time expires without any activity on the host port. The status records indicate the status of the associated port. e) 4 Active Status See previous Inactive Status record. f)

5 Activate Request

Activate request records obtain the information, necessary to activate a port. Activate requests include the status of the previous activate request for the port. The system sends these requests for a physical port whenever the port becomes disconnected. The host may respond with with one of these activate records: auto-dial, auto-answer, or deactivatefor-one-minute. For compatibility, the activate request record processes exactly like an NI311 phone request record with the following restrictions: "

"

A 1-byte status field follows the record type in the activate request. The status field indicates the status of the previous activate request. This status corresponds to the NI311 end-of-call status. Responding to an activate request with an auto-answer activate record corresponds to responding to an NI311 phone number request with a cancel-auto-dial record. However, the controller will continue to prompt the host with activate requests each time a port disconnects.

The following record types are not NI311 compatible and do not go to the host unless the system enables the associated options. g) 6 Special Request Currently, one subtype follows: 1 File Requests h) 7 Directive Status i)

8 Controller Identification

Host-to-Controller Records a) 0 Download Data 6-10

4985 Network Controller Programmer’s Guide

Page 91

SECTION 6

"

Writing the Host Program b) 1 End-of-Data c) 2 Initialization The initialization record supplies system configuration parameters. Store initialization information in a changeable file to avoid host program changes. The controller uses the initialization record to determine the block size of the host computer. The block size includes a beginning-of-record delimiter, record type, data, and an optional “end-of-line” pad character (a carriage return). Minimum block size is 258 bytes. " NOTE:

All records sent to the controller, except special commands, must have the same size. Any end-of-line pad, appended-to-records, and special commands sent to the controller must be consistent.

d) 3 Auto-answer Activate Auto-answer activate records respond to an activate request and may include optional port configuration parameters. The auto-answer activate record replaces the NI311 cancel-auto-dial record. e) 4 Auto-dial Activate Auto-dial activate records respond to an activate request, and may include optional port configuration parameters. The auto-dial activate record replaces the NI311 phone number record. Auto-answer and Auto-dial Activate records process identically. The auto-answer type is provided for backward compatibility. f) " NOTE:

5 Deactivate-for-one-minute

The following record types are not NI311 compatible, and cannot be sent to the controller unless the system enables the associated options.

g) 6 Host Directive

4985 Network Controller Programmer’s Guide

6-11

Page 92

SECTION 6

"

Writing the Host Program

The host may send a host directive in response to a special request or data request from the controller. Currently, five subtypes of host directives follow: "

1 File Upload

"

2 File Create or Load

"

3 File Delete

"

4 File Download

"

6 File Processing Abort

Special Commands In addition to the preceding records, the host may send two other commands to the controller. "

"

" NOTE:

The host must send a question mark (?) to the controller to indicate that it is ready to receive data. You can change the question mark to any other character (such as XON) with an initialization record parameter. If optional pad characters follow the question mark, they must be consistent. The host may reinitialize the controller by sending an asterisk (*). This parallels sending a slash and an asterisk (/*) to the NI311. The host must wait at least 15 seconds before sending another initialization record after sending the asterisk.

The system sends sends an asterisk before the initialization record or when the controller expects a question mark.

Logical Channels The controller has two physical ports logically numbered “0” and “1.” Logical port “0” is always the host port. Port “1” is the HHC port. There may be up to three logical channels for the HHC port. EXAMPLE:

If enabled, port “1” may have logical channels “1,” “4,” and “7.”

Records from the controller (specific to a port, such as Activate Requests) always use the logical channel that equates to the logical port 6-12

4985 Network Controller Programmer’s Guide

Page 93

SECTION 6

"

Writing the Host Program

ID. Data to or from an HHC is sequential on a logical channel and will always be port “1.” This occurs after establishing the physical connection on a port.

Data Record Length The controller data record length is 256 bytes, not including channel and record type bytes. The NI311 data record length is 128 bytes.

Enhancements The communications controller provides a number of new features: "

"

"

"

"

File Support: The controller allows the host computer to download boot files used to boot an HHC independent of the host computer. Line Discipline: The controller has a single LAN port which uses NPCP. Booting HHCs: The controller can boot HHCs and the host downloads boot files. Changing System and Port Configurations: The host computer can change the controller system and port configurations with initialization and activation parameters. DWNLRQ File Ser ver: The controller has a DWNLRQ file server which services file requests from HHCs. The file server can warm start HHCs. The server is always active except with a locked file system.

You can add support for any of the above enhancements to an existing controller host program running in an NI311 compatibility mode without changing the general structure of the host program.

4985 Network Controller Programmer’s Guide

6-13

Page 94

SECTION 6

6-14

"

Writing the Host Program

4985 Network Controller Programmer’s Guide