Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
INTERACTIVE PUMP SYSTEM
Document Type and Number:
WIPO Patent Application WO/1989/000974
Kind Code:
A1
Abstract:
An interactive pump system capable of interacting with and responding to responses from a user, having a pump (105), a central processing unit (705) connected to the pump (105), and a display and input unit (1407) including a plurality of instruction displays and being connected to the pump and the central processing unit. The pump transmits transaction data concerning fluid pumped to the display and input unit which displays the transaction data, displays one instruction display, and transfers input responses from a user to the central processing unit. The central processing unit processes the input responses and controls the pump according to the responses.

Inventors:
HOLLIDGE PETER WILLIAM (CA)
Application Number:
PCT/GB1988/000651
Publication Date:
February 09, 1989
Filing Date:
August 05, 1988
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
HOLLIDGE PETER WILLIAM (CA)
International Classes:
A41H43/02; B67D7/08; B67D7/06; B67D7/14; B67D7/22; B67D7/24; G07F13/02; (IPC1-7): B67D5/08; B67D5/14
Foreign References:
US4630754A1986-12-23
GB2028768A1980-03-12
Other References:
See also references of EP 0370055A1
Download PDF:
Claims:
CLAIMS ;
1. An interactive pump system capable of interacting with and responding to responses from a user, comprising; a pump means; a central processing unit connected to the pump means; and a display and input means including a plurality of instruction displays, and being connected to the pump means and the central processing unit; wherein the pump means transmit transaction data concerning fluid pumped to the display and input means which displays the transaction data, displays one instruction display, and transfers input responses from a user to the central pro'cessing unit, and the central processing unit processes the input responses and controls the pump means according to the responses.
2. The system of claim 1, wherein the central processing unit comprises, pump, display and input, and application task means, the pump task means controlling the pump means, the display and input task means controlling the display and input means, and application task means receiving and processing the input responses and transferring results into pump directions to the pump task means.
3. The system of claim 2, wherein: the pump task means in controlling the pump means processes the pump directions and transfers pump commands to, and receives pump responses from, the pump means; the display and input task means in controlling the display and input means, transfers display and input commands to, and receives display responses and input responses from, the display and input means, processes the display and input responses and transfers resultant display and input requests to the apprvcatioir. task means; and the application task means processes the display and input requests and transfers resultant pump directions to the pump task means.
4. The system of claim 3, wherein the pump task means additionally processes the pump responses and transfers resultant pump requests to the application task means, the application task means additionally processes the pump requests and transfers resultant display and input directions to the display and input task means, and the display and input task means processes the display and input directions.
5. The system of claim 4, wherein the central processing unit further comprises a queue, and queue task means controlling the queue, the queue task means transferring the requests from the pump task means and display and input task means to the queue, and the next request in the queue being transferred to the application task means upon an order from the application task means.
6. The system of claim 4, wherein the display and input means comprises display means and input means, the input means being connected to the central processing unit, the display means being connected to the pump means and the central processing unit, the display means displaying the instruction displays and the input means transferring the input responses to the central processing unit, and wherein the display and input task means further comprises display task means and input task means, the display task means controlling the display means by' transferring display commands to, and receiving the display responses from, the display means, the input task means controlling the input means by transferring input commands to, and receiving input responses from, the input means, the pump, display, and input task means processing the pump, display, and input responses and transferring pump, display, and input requests to the application task means, the application task means processing display, input, and pump requests and transferring resultant pump display, input and pump directions to the display input and pump task means.
7. The system of claim 6, wherein the display means comprises a graphics generator, a video mixing means connected to the graphics generator and to the pump means, and a monitor connected to the video mixing means, wherein the graphics generator is connected to the central processing unit and generates a graphic display signal representing a graphic instruction display, the pump means generates, a transaction data signal representing the transaction data to be displayed, the video mixing means __ — mixes the graphic instruction display signal" and the transaction data signal and transfers the mixed signal to the monitor to form at least part of an instruction display.
8. The system of claim 7, wherein the display means further comprises a sync generator connected to the pump means and the graphics generator, synchronizing the transaction data signal and the graphic instruction display sicpia]...
9. The system of claim 8, wherein the display means further comprises a motion instruction display signal source, a signal combining means connected to the signal mixing means and the monitor, and a switch means connected to the central processing unit, with the sync generator being additionally connected to the motion instruction display signal source, the signal combining means, and the switch means, the sync generator synchronizing the signals from the graphics generator, the pump means, and the motion instruction display source, the combining means selecting and combining from the signals from the signal mixing means and the motion instruction display signal source according to a signal sent from the central processing unit via the switch means and the sync generator to generate a combined instruction display signal, and transferring the combined instruction display signal to the monitor to form at least part of an instruction display, and wherein the central processing unit further comprises a graphics task means, a motion display task means, and a switch task means, which task means respectively control the graphics generator, the motion instruction display signal source and the switch means by transferring respective commands to, and receiving respective responses from, the graphics generator, the motion instruction display signal source, and the switch means, the graphics task means and the motion display task means forming the display task means, and the display commands and responses being provided by the graphics and the motion display commands and responses,with the graphics, motion display and switch task means processing their respective responses and transferring respective resultant requests to the application task means, and the application task means additionally processing those requests . and transferring respective directions to each of the task means.
10. The system of claim 9, wherein the display means further comprises an audio signal source, and wherein the central processing unit further comprises an audio task means controlling the audio signal source by transferring audio commands to, and receiving audio responses from, the audio signal source, the audio task means processing the audio responses and transferring resultant audio requests to the application task means, the application task means additionally processing those requests and transferring respective directions to each of the task means.
11. The system of claim 10, further comprising payment means connected to the central processing unit, accepting payment and transferring payment data to the the central processing unit, and wherein the central processing unit further comprises payment task means controlling the payment means by transferring payment commands to, and receiving payment responses from, the payment means, processing the payment responses and transferring resultant payment requests to the application task, the application task addrfrioTralZy processing the payment requests and tran fering respective resultant directions to each of the task means.
12. The system of claim 11, wherein the payment means further comprises a card reader and a cash reader, each reader being connected to the central processing unit, accepting the payment and transferring the payment data to the central processing unit.
13. The system of claim 12, wherein the payment means further comprises a card and note controlling means being connected between the central processing unit and the card and cash readers, the card and note controlling means controlling the card reader and the cash reader.
14. The system of claim 13 further comprising kiosk computing means connected to the central processing unit, accepting point of sale data including the transaction data from the pump means and controlling the pump means via the central processing unit, and wherein the central processing S73 unit further comprises point of sale data task means and kiosk computer task means, the point of sale task means communicating the point of sale data to the kiosk computer and the kiosk computer task means allowing the kiosk computing means to control the pump means by transferring respective commands to, and receiving respective responses from, the kiosk computing means, the point of sale data and kiosk computer task means processing their respecitve responses and transferring respective resultant requests to the application task means, and with the application task means additionally processing those requests and transferring respective directions to each of the task means.
15. The system of claim 14, further comprising external source means being connected to and communicating with the central processing unit for diagnosing respective task means problems.
16. The system of claim 15, wherein the external source means further comprises a modem connected to the central processing unit.
17. The system of claim 16, wherein the input means comprises a touch sensitive screen and associated electronics, the screen being positioned over the monitor and accepting input responses from a user. _ _ .
18. The system of claim 5, wherein the display and input means comprises display means and input means, the input means being connected to the central processing unit, the display means being connected to the pump means and the central processing unit, the display means displaying the instruction displays and the input means transferring the input responses to the central processing unit, and wherein the display and input task means further comprises display task; irteairs' and input task means, the display task means controlling the display means by transferring display commands to, and receiving the display responses from, the display means, the input task means controlling the input means by transferring input commands to, and receiving the input responses from, the input means, the pump, display and input task means processing the pump, display, and input responses and transferring pump, display and input requests to the queue via the queue task means, the application task means processing display, input, and pump requests and transferring resultant display, input and pump directions to the display, input and pump task means.
19. The system of claim 18, wherein the display means comprises a graphics generator, a video mixing means connected to the graphics generator and to the pump means, and a monitor connected to the video mixing means, wherein the graphics generator is connected to the central processing unit and generates a graphic display signal representing a graphic instruction display, the pump means generates a transaction data signal representing the transaction data to be displayed, the video mixing means mixes the graphic instruction display signal and the transaction data signal and transfers the mixed signal to the monitor to form at least part of an instruction display.
20. The system of claim 19, wherein the display .means further comprises a sync generator connected to the pump means and the graphics generator, synchronizing the transaction data signal and the graphic instruction display signal.
21. The system of claim 20, wherein the display means further comprises a motion instruction display signal source, a signal combining means connected to the signal mixing mean's and the monitor, and a switch means connected to the central processing unit, with the sync generator being additionally connected to the motion instruction display signal source, the signal combining means, and the switch means, the sync generator synchronizing the signals from the graphics generator, the pump means, and the motion instruction display source, the combining means selecting and combining from the signals from the signal mixing means and the motion instruction display signal source according to a signal sent from the central processing unit via the switch means and the sync generator to generate a combined instruction display signal, and transferring the combined instruction display signal to the monitor to form at least part of an instruction display, and wherein the central processing unit further comprises a graphics task means, a motion display task means, and a switch task means, which task means respectively control the graphics generator, the motion instruction display signal source and the switch means by transferring respective commands to, and receiving respective responses from, the graphics generator, the motion instruction display signal source, and the switch means, the graphics task means and the motion display task means forming the display task means, and the display commands' and, responses being provided by the graphics and the motion display commands and responses,with the graphics, motion display and switch task means processing their respective responses, with the graphics and switch .task means transferring respective resultant requests to the application task means, and the motion display task means transferring its resultant requests to the queue via the queue task means, and the application task means additionally processing those requests and transferring respective directions to each of the task means.
22. The system of claim 21, wherein the display means further comprises an audio signal source, and wherein the central processing unit further comprises an audio task means controlling the audio signal source by transferring audio commands to, and receiving audio responses from, the audio signal source, the audio task means processing the audio responses and transferring resultant audio requests to the queue via the queue task means, the application task means additionally processing those requests and transferring respective directions to each of the task means.
23. The system of claim 22 further comprising payment means connected to the central processing unit, accepting payment and transferring payment data to the central processing unit, and wherein the central processing unit further comprises payment task means controlling the payment means by transferring payment commands to, and receiving payment responses from, the payment means, processing the payment responses and transferring resultant payment requests to the queue via the queue task means, the application task additionally processing the payment requests and transferring respective resultant directions to each of the task means.
24. The system of claim 23, wherein the payment means further comprises a card reader and a cash reader, each reader being connected to the central processing unit, accepting the payment and transferring the payment data to the central processing unit.
25. The system of claim 24, wherein the payment means further comprises a card and note controlling means being connected between the central processing unit and the card and cash readers, the card and note controlling means controlling the card reader and the cash reader.
26. The system of claim 25 further comprising kiosk computing means connected to the central processing unit, accepting point of sale data including the transaction data from the pump means and controlling the pump means via the central processing unit, and wherein the central processing unit further comprises point of sale data task means and kiosk computer task means, the point of sale task means communicating the point of sale data to the kiosk computer and the kiosk computer task means allowing the kiosk computing means to control the pump means by transferring respective commands to, and receiving respective responses from, the kiosk computing means, the point of sale data and kiosk computer task means processing their respecitve responses and transferring respective resultant requests to the queue via the queue task means, and with the application task means additionally processing those requests and transferring respective directions to each of the task means.
27. The system of claim 26, further comprising external source means being connected to and communicating with the central processing unit for diagnosing respective task means problems.
28. The system of claim 27, wherein the external source means further comprises a modem connected to the central processing unit.
29. The system of claim 28, wherein the input means comprises a touch sensitive screen, and associated electronics, the screen being positioned over the monitor and accepting input responses from a user. SUBSTITUTE SHEET.
Description:
INTERACTIVE PUMP SYSTEM

The invention relates to pump systems more particularly but not exclusively the invention relates to gasoline pump interactive systems . BACKGROUND OF THE INVENTION

For many years gasoline pumps were mechanical devices. They did not accept payment from customers prior to allowing the customer to pump gas. In self service operations, customers would often drive away from the station without paying for gas which they had pumped into their cars.

These mechanical devices did not keep track of transaction data for individual transactions.

In order to diagnose any problems the pump may have had a serviceman was required to actually be at the pump location.

In the electronic age pumps are made to operate on electronic systems. These electronic pumps can accept prepayment when equipped with a card and note reading facility. Transaction data is displayed to customers via liquid crystal displays similar in function and layout to the mechanical display system used in mechanical pumps. The electronic pump can keep track of transaction data for itself. Neither the mechanical pump nor the electronic pump is very user friendly. A customer encountering the pump for the first time is often intimidated by the cold look of the solely numerical display and the separate card and note reader. Even to a veteran self service pump user,

SUBSTITUTE SHEET

pump problems encountered during use can cause this feeling of intimidation. The provision of a long list of printed instructions does not improve the situation.

The object of the invention is to provide improved prepayment, point of sale information, display, instruction, remote system problem diagnostic, and remote problem correction capabilities.

SUMMARY OF THE INVENTION

An interactive pump system capable of interacting with and responding to responses from a user, comprises; a pump means; a central processing unit connected to the pump means; and a display and input means including a plurality of instruction displays, and being connected to the pump means and the central processing unit; wherein the pump means transmits transaction data concerning fluid pumped to the display and input means which displays the transaction data, displays one instruction display, and transfers input responses from a user to the central processing unit, and the central processing unit processes the input responses and controls the pump means according to the responses.

The invention can be capable of taking a user through a transaction with step by step instruction displays dependant on the input responses of the user .

Additionally the central processing unit may run separate tasks controlling the pump means and the display and input means, and an application task receiving and processing the input responses and transferring resultant pump directions to the task controlling the pump means.

The means of control may include the transfer of

' SUBSTITUTE SHEET

commands to, and receiving of responses from, the pump means and the display and input means. The display and input means processing the responses from the user and transferring resultant requests to the application task. The application task processing the requests and transferring directions to the pump task.

Similarly the pump task can be capable of processing responses from the pump means and transferring resultant pump requests to the application task. The application task would be capable of processing the requests and transferring resultant directions to the display and input task. The display and input task processes the display and input directions.

The system can employ a queue and queue task controlling the queue. The queue would accept requests from the controlling tasks and transfer them to the application task when required. Thus the system is capable of responding to responses from any of the controlling tasks.

The display and input means may be divided into separate display means and input means . Correspondingly the display and input task would be divided into a display task and an input task with corresponding command, response, requests, and direction flow. The application task would process each of the requests and transfer resultant directions;

The display means can employ a graphics generator, a video mixer, and a monitor. The graphics generator generating graphic displays. The mixer mixing the graphic displays with the transaction data and the monitor

displaying the resultant instruction display.

A sync generator can be used to synchronize the transaction data with the graphic displays.

A motion display source may be used as an alternate source of displays. The motion display source output and the mixer output being selected and combined in a video combiner. The output of the video combiner being displayed on the monitor. The sync generator could be employed to synchronize the transaction data and both instruction display sources. The application task can direct the selection and combining through a switch task controlling a switch sending signals to the sync generator.

An audio signal source can be used by the display means to create audio instruction displays. Payment means with a corresponding prepayment task transferring commands to and receiving responses from the payment means can be used to accept credit cards or cash prior to using the pump means. The payment means may include a card reader and a cash reader controlled by a card note controller. The card note controller being controlled by the payment means .

A kiosk computer added to the system can keep track of point of sale data received from the pump means via the central processing unit and control the pump via the central processing unit for transactions which do not employ the card and cash reader.

An external source connected to the central processing unit can be employed to .access the central processing unit for remote diagnostics and remote system

__. L__. _- correction. ϋ

The input responses can be taken from a touch screen connected to the central processing unit.

The monitor can display graphic or motion instruction displays taking the customer step by step through the transaction, while the touch sensitive screen accepts the input responses from the user. The instructions displayed at any one time can be made to relate solely to the action with which the customer is involved at any given time. The display can relate a great deal " of information while being simple, colourful and pleasing to the eyes and ears.

The task structure resists system failure caused by problems in any one task. System problems which are capable of software solutions may be corrected at remote locations using the external source.

The kiosk computer may be added to the system to keep track of point of sale information and to possibly forward the point of sale information to a centralized host computer. The kiosk computer could also reset price information at the pump. The price information may have originally been relayed from the host computer.

Through the modem connection the system may be used to authorize credit cards via a remote authorization computer.

A laser disc player and signal decoder may be employed as the motion display signal source. BRIEF DESCRIPTION OF THE DRAWINGS

For a better understanding of the present

invention, and to show more clearly how it may be carried into effect, reference will now be made by way of example to the accompanying drawings, which show a preferred embodiment of the present invention, and in which; Figure 1 is a pump system hardware block diagram according to the preferred embodiment of the present invention; Figure 2 is a block diagram of a pump circuit employed in the system of Figure 1; Figure 3 is a block diagram of a video circuit employed in the pump system of Figure 1; Figure 4 is a block diagram of an audio circuit employed in the pump system of Figure 1; Figure 5 is a block diagram of a touch circuit employed in the pump system of Figure 1;

Figure 6 is a block diagram of a payment circuit employed in the pump system of Figure 1; Figure 7 is a block diagram of a kiosk computer circuit employed in the pump system of Figure 1;

Figure 8 is a block diagram of an external source circuit employed in the pump system of

Figure 1;

Figure 9 is a detailed block diagram of a data decipher unit employed in the video circuit of Figure 3; Figure 10 is a block diagram of a character generator used in the video circuit of Frgure 3;

-β-

Figure 11 is a block diagram of a sync generator used in the video circuit of Figure 3; Figure 12 is a block diagram of a video combiner used in the video circuit of Figure 3; and

Figure 13 is a block diagram of the task structure according to the preferred embodiment of the present invention. Figure 14 is a perspective view of a gasoline station island employing a pump system according to the preferred embodiment of the present invention. Figure 15 is a drawing of a language choice display employed in the system of Figure 14.

Figure 16 is a drawing of preset choices display employed in the system of Figure 14. Figure 17 is a drawing of payment choices display employed in the system of Figure 14. Figure 18 is a drawing of card selection display employed in the system of Figure 14. Figure 19 is a drawing of thank you display employed in the system of Figure 14. Figure 20 is a drawing of pay at the kiosk display employed in the system of Figure 14.

Figure 21 is a drawing of cash deposit display employed in the system of Figure 14. Figure 22 is a drawing of receipt and refund display employed in the system of Figure 14.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

Reference will now be made to figure 1 showing system hardware 101 for a gasoline pump interactive system. The hardware 101 is composed of eight elements; system microcomputer element (PC) 103, pump element 105, video element 107, audio element 109, touch element 111, payment element 113, kiosk microcomputer element 115, and external source element 117.

The microcomputer 103 is connected to elements 105 through 117. The pump 105 is additionally connected to the video element 107.

As shown in figure 14, the pump 105 sits on a gasoline station island 1403. The pump , 105 shown is actually designed to handle two systems. The three hoses 1405 on one side of the pump 105 can be used by one customer while the three hoses on the other side are used by another. Correspondingly there are shown two interactive columns 1407. The columns 1407 each service one system. Each column 1407 contains a video, audio, touch, and payment element 107, 109, 111, 113. The touch and video elements 111, 107 lie one behind the other and therefore occupy the same space on the figure. Column and pump speakers 409, 411, part of the audio element 109, appear on the column 1407 and the pump 105. The PC and external source elements 103, 117, not shown, are shared by two systems.

The kiosk computer 115, shared by all the systems in the station, is situated in a kiosk, not shown, " central to the station.

- (O -

Reference will now be made to figures 1 through 8 which detail how the various elements 103 through 117 make up seven corresponding circuits; pump circuit 201, video circuit 301, audio circuit 401, touch circuit 501. payment circuit 601, kiosk circuit 701, and external circuit 801. SYSTEM MICROCOMPUTER

The PC 103 maintains control over all functions of the system. A Tandy HD3000, AT class, was used as the system PC 3 in the preferred embodiment. The PC 103 operated on the QNX operating system manufactured by Quantum Software Systems, Ltd. The compiler supported the C computer language.

It will be evident to those skilled in the art that it is not necessary to use this particular brand of microcomputer " , operating system or language. Any computer of sufficient size and speed, having the required number of input/output lines, and supporting a task driven operating system with intertask communication will be suitable. The system software which controls the PC 103 will be described later in this description. PUMP CIRCUIT

Reference will now be made to figure 2 in detailing ' the pump circuit 201. The pump 105 used in the preferred embodiment was a LTS Sierra 7000 multiple product dispenser (MPD) having six hoses capable of serving two customers one of three different types of gasoline at any one time.

The liquid crystal display of the pump 105 has been removed and the αisplay lines fed to the PC 103 and the

- I I- video circuit 301. The pump 105 connection to the PC 103 is a 20 mAMP current loop control link 203. The information flow on the control link is full duplex. The microcomputer 3 is an active transmitter and receiver to the pump passive receiver and transmitter. Signal speed is selectable between 4800 and 1200 Baud. In the preferred embodiment 4800 Baud was used.

Data transfer is asynchronous. Character length is 7 data bits with one even parity bit. There is one start bit and two stop bits. The character set is in ASCII code. The bit sequence is least signficant bit first while the byte sequence is most signficant byte first. The byte sequence therefore starts with the beginning of the message. It is not necessary to use this particular pump to produce the, desired results, an electronically controlled pump having similar functions would be suitable. Modifications would have to be made to the system software and possibly the hardware connections to correspond with the changes in the pump 105 control sequence and command set. The control sequence and command set of the pump

105 used in the preferred embodiment will now be outlined:

CONTROL CHARACTERS

Start Character from PC or MPD Positive Acknowledgment from MPD Negative Acknowledgment from MPD End of Data Block Block Check Character

The BCC Character is obtained by taking the exclusive - or (XOR) across all 7 bits of the ASCII character • for all transmitted characters excluding the BCC character .

-II-

SPECIAL CHARACTERS length

SEQ 1 = Sequence, range 20H to 5FH for PC, 60H to 7EH for MPD ID 1 = Pump no. 30 Hex (0) + PUMP no.

1 = Hose no. 30 Hex (0) + HOSE no. (1, 2 or 3) eg. ID of Pump 12 Hose 2 = 3CH, 32H

Note: ID of HOSE #0 means "any hose' and PUMP #0 means 'this pump'.

PROTOCOL SPECIFICATION

The Protocol consists of a series of command strings sent from the PC 103 to the MPD 105. The MPD 105 responds to these commands by returning Data or Status or by controlling hardware within the MPD 105. There are two modes of the application, an event driven system where the MPD 105 generates event-messages as a result of actions in the MPD 105 and a polling system where the PC 103 is interrogating the MPD 105 to find out about actions of the MPD 105. In both instances., actions of the MPD 105 are controlled by the PC 103. SUMMARY OF MESSAGES

A. Events

Only one type of event message exists: the MPD 105 status message with the same contents as returned in function *S' .

B. Functions

Functions are initiated by the PC 103 controlling the MPD 105 and replied by the MPD 105. 1. Functions for use in transactions

Function Action Reply

IP αet status " MPD Status

Authorize pump MPD Status

-l >-

'D' get transaction pump MPD. status + transaction data

'N' pump motor on MPD status

'F * pump motor off MPD status

'T' set sale complete MPD status

E' set pre-pay data *L'

'R' get pre-pay pre-pay status, reply 'X','M'

Functions for use other than transactions

'G' set MPD prices K'

'B' read back MPD prices price file data as in 'G'

'0' get options MPD status and option status

'P' reset Power-Up bit MPD status

1 V read MPD S/W version MPD version #

'X' read Cash Totals MPD Cash Totals; Volume and $$ Product Code 'C

Y* read Credit Totals MPD Credit Totals;

Volume / $$ Product Code 'C

TYPICAL MESSAGE FORMATS AND ERROR REPLIES Event message: originator MPD

PC ENQ SEQ ID data DEL BCC MPD

Function message: originator PC

PC BCC. DEL Func./Data ID SEQ ENQ MPD ACK SEQ ID data - DEL BCC

4- negative reply: by MPD

PC NAK SEQ ID ESTAT DEL BCC MPD -

ESTAT: a 2-byte error status with the following interpre ation: seguence 1 : Byte 1 B7 - B4 B3 - B0

0100 0001 = time out

0100 0010 = message length

0100 0011 = BCC

0100 0100 = Sequence range

0100 0101 = Sequence match

0100 0110 = ID invalid

0100 0111 = command out of context

0100 1000 = command unknown

Byte 2 always 80H ( <_■* ) sequence 2 :

Byte 1 always 80H ('(_" )

HV.. __ BO

-1U1 IliH " 1 r.e I IlV.l : pump on inval d pre-pay not received prices not received data bad (not ASCII) data not accepted

Events

The MPD 105 will optionally send status messages as events.

Any change of the contents of the regular status bytes is sent as an event once only. The status bytes reflect the operational status of the MPD 105.

Event message format:

PC ENQ SEQ ID STATUS DEL BCC MPD v

BCC DEL ID SEQ ACK

or:

BCC DEL ID SEQ NAK

LIST OF EVENTS: for details see 'S* command. Transaction related

Hook Status

Pump motor Command Status

Pump reset complete (888-blank-all zero-sequence) Normal/Attended Mode Sale Complete

Error related

Power Up Restart/System Restart Pump Time Out

Temperature Measurement Failure Pulser Failure

' Local Price change Pump Not In Service (find out more in Options)

1. CODE « S-

This command returns MPD 105 pump status and error

. nformaL ion at jnv j me

B2 = Zero Fuel - Zero = 0 B3 = Attended/Manual Mode - Manual = 1

B4 = Sale complete = 1 *

B5 = 0 - future: Units - Litres/USG; USG =1

B6 = 1

B7 = 0 Second Byte- BO = Power up restart, system restar **

Error Status - Bl = Pump Time Out

B2 = Temperature Failure

B3 = Pulser Failure

B4 = Local Price Change = 1 B5 = Pump Not In Service = 1;- see Option

Status

B6 = 1 B7 = 0

Notes: * The Sale Complete bit indicates that the PC 103 has processed this sale, bit is set to 'not complete* by handle 'on hook' at the end of a transaction, (see function 'T' )

** The power up restart / system restart flag is latched until acknowledged by the PC 10.3 by sendinσ function 'P*.

2. CODE *C

This command initiates a MPD 105 segment test and reset and authorizes the MPD 105 for a new transaction. PC BCC CΞL 'C ID SEQ ENQ MPD ^

ACK SEQ ID STATUS DATA DEL BCC

The 'Zero Fuel' bit of the first status byte is interrogated as an indication of a successful MPD 105 Clear & Authorization Cycle. The pump motor is turned on subsequently, a separate Pump ON command is not reguired.

CODE

This command returns last/current pump transaction data along with status information at any state of a transaction.

PC BCC DEL 'D' ID SEQ ENQ MPD ACK SEQ ID STATUS DATA DEL BCC

Status Format:

Identical to CODE 'S'

Data Format:

PPU [cents*10] = 4 Bytes (XXX. )

Volume [units] = 6 Bytes (xxx.xxx) Gallons or Litres

Sales [cents*10] = 6 Bytes (xxx. x ) Unrounded

Product code = 1 Byte upper case ASCII 'A' H' . for CASH price lower case ASCII 'a' h' for CREDIT price

Note: a) Decimal point is implied b) all data is in ASCII.

CODE *N'

This command initiates switching the Pump Motors on.

PC BCC DEL 'N' ID SEQ ENQ MPD _ _

ACK SEQ ID STATUS DEL BCC _

The Status is checked for successful 'Pump Motors

On'

5. CODE 'F'

This command initiates switchinσ the Pump Motors off.

PC BCC DEL 'F* ID SEQ ENQ MPD ACK SEQ ID STATUS- DEL BCC

-n-

This command sets the Sale Complete bit in the status byte.

PC BCC DEL 'T * ID SEQ ENQ MPD ACK SEQ ID STATUS DEL BCC

The status is checked for 'Sale Complete'.

7. CODE *E'

This command sends a string of Pre-Payment Data to the

MPD 105.

PC BCC DEL 'E' ID SEQ ENQ MPD -

ACK SEQ ID 'L' DEL BCC <

BCC DEL DATA ID SEQ ENQ _ ^

Data Format:

Pre-Payment Amount [cents] = 4 Bytes (xx.xx) If there is no Pre-Payment Data within 3 seconds of the MPD 105 sending the 'OK' response, or if there is a break in the Pre-Payment Data Transmission greater then 3 seconds then the MPD 105 will abort the 'E' command and return to a general 'LISTEN' mode. If any errors are detected in the Transmission,

Data or setting up of the Pre-Payment Data within the MPD

105, then an error is indicated that can be extracted via code R- .

All Data is in ASCII numeric. 8. CODE -R'

This command usually follows a code 'E' command and extracts the status of the setting up of the Pre-Payment file within the MPD 105.

-ιs-

PC BCC DEL * R * ID SEQ ENQ} MPD

ACK SEO ID RSTAT DEL BCC <- —

RSTAT Format:

Consists of 1 Byte containing ASCII 'M* or *X' 'M' indicates a successful Pre-Payment setup 'X' indicates an error during code 'E' 9. CODE 'G' This command primes the MPD 105 to receive a string of Central Product Price Data.

PC BCC DEL *G' ID SEQ ENQ MPD ^

ACK SEQ ID *K' DEL BCC "

BCC DEL DATA ID _SEQ ENQ

Data Format

Hosel PPU-cash,- PPU-credit 8 bytes Hose2 PPU-cash, PPU-credit 8 bytes

Hose3 PPU-cash, PPU-credit 8 bytes total message: 24 bytes

Structure of PPU: =PPU [cents*10] =4 Bytes (xxx.x) The hose number is implied by the position of PPU. If there is no Product Data within 3 seconds of the MPD 105 sending the 'OK RESPONSE', or if there is a break in the Product Data Transmission greater than 3 seconds then the MPD 105 will abort the 'G' command and return to a general 'LISTEN' mode.

12. CODE 'P'

This command resets the Power-Up bit of the MPD 105 status byte which was set upon power-up/restart of the MPD 105.

PC BCC DEL *P' ID SEQ ENQ MPD >

ACK SEQ ID STATUS DEL BCC < -_

Status format: Identical to CODE 'S*

13. CODE 'V*

This command returns the MPD 105 S/W Version number.

MPD

RR = Revision # [00 - 99]

Date of origin: YY = Year [00 - 99]

MM = Month [01 - 12]

DD = Day [01 - 31] all data is in ASCII.

14. CODE 'X' Read Cash Totals form MPD ' 105 by Hose. Only valid

Hose # will be replied. Otherwise a NAK message will be sent.

-10-

If any errors are detected in the transmission,

Data, or setting up of the Central Price File within the MPD 105, then the appropriate error bit is set in the error byte of the Pump Status (extracted via CODE 'S').

All Data is in ASCII Numeric, decimal point is implied. 10. Code 'B*

This command allows the PC 103 to read back the Product Price file in the MPD 105.

PC MPD

Data Format: Identical to code *G' 11. CODE '0*

PC MPD

Options Format:

First Bytes - B0 = Meter factor(s) not valid or not calibrated

Bl = Price(s) (Cash) not valid (eg. 0)

B2 = MPD is in Manager Mode

B3 = MPD is in Inspector Mode

B4 = Handle(s) Off Hook upon startup or return from Manager Mode B5 = 0 B6 = 1 B7 = 0

Second Byte

- 2.1-

PC MPD

Data Format:

Cash Volume [litres] = X XXX XXX XXX.XX 12 bytes

Credit Sale [Dollars] = X XXX XXX XXX.XX 12 bytes

Product code to indicate Cash = 'C* 1 byte

15. CODE Υ' Read Credit Totals from MPD 105 by Hose. Only valid Hose # will be replied. Otherwise a NAK message will be sent.

PC BCC DEL 'Y' ID SEQ ENQ MPD ACK SEQ ID DATA DEL BCC

<

Data Format:

Credit Volume [litres] = X XXX XXX XXX.XX 12 bytes Credit Sale [Dollars] = X XXX XXX XXX.XX 12 bytes Product code to indicate Credit = 'c' 1 byte

Both messages: the decimal point is implied.

VIDEO CIRCUIT

Reference will now be made to figure 3 which depicts the video circuit 301 in detail. The microcomputer 103 controls three video sources; a graphics board 303, a laser video disc player 305, and the pump 105.

The output of the player 305 is sent to an NTSC to R6B decoder 307.

To produce a usable video signal the pump data is deciphered by a data decipher unit 309. The output of the data decipher unit 309 is connected to a character generator 311.

-aα-

The output of the graphics board 303, the decoder 307, and the character generator 311 are fed into a video combiner unit 312.

The graphics board 303, player 305, data decipher unit 309, character generator 311, and video combiner unit 312 are each connected to a sync generator 313.

The output of the combiner 312 is sent to a red-green-blue monitor 317.

A switch 319 is connected to the combiner 312. Graphics Board

The graphics board 303 used in the preferred embodiment is an AT&T True Vision advanced raster graphics adaptor, Targa M8. The User's Guide for this adaptor dated September 1986, published by AT&T Electronic Photography and Imagery Center, Indianapolis, Indiana, is hereby incorporated by reference. As the system software used on the PC 103 is written in the C language, as has been mentioned previously, a C language source file diskette of routines for the Targa M8 supplied by AT&T's EPICenter was used.

It is not necessary to use this particular board - any graphics equipment capable of storing frames and generating, in conjunction with the PC 103 and an external sync signal, red-green-blue video signals from the stored frames would be suitable.

The features of the graphics board 303 used in the preferred embodiment include the following: Display Memory:

-13-

A digitized image is stored as a 512-row by

512-column array in the graphics board 305 display memory. Each pixel is saved as an 8-bit value in the 256 K bytes of display memory. The memory is dual-ported enabling the PC 103 to read and write information while the graphics board 303 maintains the display output. The graphics board 303 uses row address able random access memory (RARAM). The display memory is bank switched into a single 64 K memory segment in the PC 103 memory address space. Input Lookup Tables:

256 input levels can be mapped to new values by eight input tables. Output Lookup Tables:

The graphics board 303 can display 256 colours from a palette of over 64 million colours (24 bits). The output lookup tables allow the PC 103 to generate full colour RGB images. Eight lookup tables may be selected from. The lookup tables may be written into by setting an individual colour component (i.e. red, green or blue) of a map entry.

Disp1ay Modes:

The graphics board ' 303 may be employed in the memory mode displaying the image stored in its display memory. In this mode captured frames or computer generated frames may be displayed. As well the border may be set to any colour. Genlock:

The graphics board 303 can be operated in two ' synchronization modes. In the preferred embodiment the

-14- graphics board 303 s always operated in the above mode. In slave mode, it 303 synchronizes with an input video signal.

The graphics board 303 can synchronize to a composite sync signal.

Laser Disc Player

The player 305 used in the preferred embodiment was a McDonnell Douglas LFS-4400. The connection to the PC 103 is via an RS-232 series connector.

The player 305 accepts, among others, the following commands: Acx - Audio Control:

"c" is the audio output port of the player 305 (c=l for CH-1, c=2 for CH-2 ) to which the command is applied, and "x" corresponds to the following code (1 to 5) which indicates the audio source used. 0 : Output channel OFF

3 : Normal audio of disc channel 1 is output 4 : Normal audio of disc channel 2 is output L - Load the disc: It may be used to reload a disc that has unloaded, provided that the disc has not been removed. If the "L" command is received when no disc is in the player 305, or if the disc has already been loaded, the load command will be discarded and the error flag will be raised. Status "N" is reported while the load operation is in progress. Status "R" is reported following successful completion. Pxxx-xx - Piav no tc frame number xxxxx:

-is-

By inputting a command consisting of P followed by a number of up to five digits, the disc will be played from the present frame up to the frame corresponding to the specified frame number. If the specified frame number is larger than the present frame number, forward play will take place. Conversely, if it is smaller than the specified frame number, reverse play will take place. Status "P" is returned. Sxxxxx - Seek: By inputting a command consisting of S followed by a number of up to five digits, you can perform a fast search operation from the present frame to the specified frame. Once the specified frame is reached, video will be muted, until the unit is commanded into the play mode using Pxxxxx. if a seek is commanded to a frame outside the playable area of the disc, such as a lead-in or lead-out frame, then the player 305 will seek to the first or last playable frame, whichever is nearest to the target, and the error flag will be raised. Status Reporting

The PC 103 may determine the state of the player 305 by requesting a status report (transmitting an ASCII "?"). The player 305 will send a report only when requested to do so by the PC 103. The status report consists of eight characters. The first five characters are the present frame number, the -sixth character indicates the present state of the player 305, and the .seventh character is used to pass RCU keystrokes to the microcomputer 103. A carriage return ends the message.

-*Zfe-

Status Report Format Present state of the player

(Refer to STATUS CODES) Present frame number ■ 08375 P L CR RCU keystroke

(Refer to the table below) Carriage return —

Status Codes:

B - A command is in the command buffer awaiting execution E - An error has occurred since the previous status request. K - An RCU keystroke is available.

N - Load or Unload operation is in progress, player is unloaded, or current frame is on lead-in or lead-out. O - OFF LINE

P - Play operation is in progress. R - Disc is ready to play, no operations are in progress.

- 1.1- S - Seek operation is in progress.

As the output of the player 305 is an NTSC signal.

It must be decoded to become a red-green-blue video signal to be used in conjunction with the graphics board 303 output signal. Thus the output of the player 305 is sent to an NTSC to RGB decoder 307.

Pump Video

A third video source, the pump 105, constantly outputs serial transaction data signals. The signals are a repeated serial string, each string being equivalent to the data contained in a pump D command without the product code information. A load pulse used to synchronize with the pump data is sent on a separate line every three strings, or 384 bits. The data is clocked out of the pump 105 by a pump clock. The data is sent in the form necessary to turn on the liquid crystal display segments as this was the original purpose of the pump 105.

Data Decipher Unit:

Reference will now be made to figure 9. The data decipher unit 309 employs a IK by one line serial random access memory buffer 901. The data input to the buffer 901 is taken from the serial data output of the pump 105 as shown by the incoming arrow 903. The address in the buffer

901 is supplied by a write address generator 905 through one of two inputs to a two to one multiplexer 907. The input to the generator 905 is a clock pulse from the pump 105 clock as shown by the incoming arrow 909. -The generator 905 begins to count clock pulses when it is enabled by the output of an

R-S flip flop 911. The write enable input to the buffer 901

-IS- is connected to the generator 905 enabling data to be written into the buffer 901 while the generator 905 is correspondingly enabled.

The generator 905 is initially enabled by a signal from a microcontroller 913 to the R-S flip flop 911. After

384 bits have been sent along the data line 903 the pump 105 sends a load pulse to the flip flop 911 on a load pulse line

912. The pulse toggles the flip flop 911 disabling the generator 905 and the buffer 901. The microcontroller 913 is made aware of the change in status by a second line connecting the microcontroller 913 to the flip flop 911. The address of the last bit of information written into the buffer 901 is provided to the microcontroller 913 on an output line directly connecting the generato ' r 905 and microcontroller 913. '

The microcontroller 913 verifies the validity of the data written into the buffer 901 by reading certain bits out of the buffer 901. The read address is sent by the microcontroller 901 to a read address port 915 which is the second input to the multiplexer 907. The select input to the multiplexer 907 is connected to the output of the flip flop 911 and would have been previously altered by the load pulse. After validating the data the microcontroller 913 causes bits of data from the buffer 901 to move into a shift register 917. The data is shifted put of the register 917 on seven parallel lines to a lookup table 919. Shifts are caused by an input to -the register 917 from the clock output

-23- of the microcontroller 913. The lookup table 919 converts the segment generating data from the register 917 to four bit ASCII numerals (0 through ' 9). Once all of the information in the buffer 901 is thus converted, • the microcontroller 913 resets the flip flop 911. The buffer 901 and generator 905 are then free to resume accepting data from the pump 105.

A further input to the microcontroller 913 is an output field identification line 921. The microcontroller 913 has three further outputs; a four bit parallel data in line 923, a five bit parallel write address line 925 and a two bit parallel control line.

When the output field line 921 changes state, the microcontroller 913 sends the four bit numerals along the data line 923 to be written at the addresses given by the line 925. Character Generator:

Reference will now be made to figure 10. A one kilo bit by four output bits serial random access memory buffer 1001 has the control and data in lines 927, 923 as inputs and the write address line 925 as a selectable input.

The addresses in the buffer 1001 for the numerals on the data in line 923 are given on the write address line 925.

The other selectable input to the buffer 1001 is a read address line 1003. When all of the character data from the data decipher unit 309 has been written into the buffer 1001, the read address line 1003 is selected. The data in the buffer 1001 at the address given by the line 1003 is put on a four bit data out line to a lookup table 1005-. The

output of the buffer 1001 is used as a pointer to the addresses in the lookup table 1005. The lookup table 1005 contains the character graphics, for the line presently being read, corresponding to the data originating on the pump data line 903. The output of the lookup table 1005 is blank until the correct line is given on a four bit character line number input 1007 to the lookup table 1005. The signal 1007 dictates that characters are in fact to be generated as the correct line number on the screen has been reached. The output of the lookup table is an eight-bit parallel signal to an eight to one multiplexer 1009. Only one output line is necessary as the characters displayed on the screen are either white or black. The use of the multiplexor 1009 can increase the bit rate up to 14.3 MHz for improved character resolution. Video Combiner

Reference will now be made to figure 12, detailing the structure of the combiner 312. The three line red-green-blue video signal from the graphics board 303 is fed into an input 1202 of a video mixer 1201 where it is overlayed with the one bit character signal 1013 from the character generator 311. The character signal 1013 is fed through another input 1203 including a potentiometer to adjust the signal level before it enters the video mixer 1201. The output of the video mixer 1201 is a three line red-green-blue signal fed through the potentiometers 1205, only one representative potentiometer being shown, to a two to one video multiplexer 1207. The other input to the multiplexer 1207 is a three line red-green-blue signal from

the output of the NTSC decoder 307. The select input of the multiplexer 1207 is a one bit video control signal 1208.

The output of the multiplexer 1207 is a three line red-green-blue signal which is fed to a clamp 1209. The red- green-blue outputs ' of the multiplexer 1207 are clamped during blanking time to make them insensitive to average picture level. The output of the clamp 1209 is a three line red-green-blue signal fed through low output impedance driving amplifiers 1211 to produce an output red-green-blue signal 1213.

Sync Generator

Reference will now be made to figure 11 in detailing the sync generator 313. A free-running 14.3 MHz. crystal oscillator 1101 clocks a horizontal counter 1103. The output of the horizontal counter 1103 is a ten-bi.t address signal connected to a pair of programmable read-only memories (PROMs) 1105, 1107. The outputs of PROM 1105 are latched by a latch 1109, whose outputs are the control line 1011 and the read address line 1003 to the character generator 311.

The three outputs of the PROM 1107 are latched by latch 1111. One of the outputs of the latch 1111 is a one bit signal 1113 to the character generator 311. The second output signal is a three-bit signal to a composite sync PROM 1115. The third output of the latch 1111 is a one bit signal to a vertical counter 1117.

The output of the vertical ' counter 1117 is fed to a vertical PROM 1119 which produces three outputs. The three outputs are fed through a latch 1121 producing a

three-bit signal to the composite sync PROM 1115, the four bit character line number signal 1007 to the character generator 311, and the one bit output field ID signal 921 to the data decipher unit 309. - The outputs 1011, 1003, 1113 and 1007 to the character generator 311 determine the horizontal and vertical positioning of the characters from the pump 105 in a screen.

The output field ID signal 921 causes the numerals from the data decipher unit to be written to the character generatorand eventually the combiner 312 at the same rate as the frame lines from the graphics board 303 are sent to the combiner. This causes the characters from the pumps 105 to be displayed on an even or odd line to eliminate flicker when they are displayed.

A third input to the PROM 1115 is a two bit split control signal 1123. This signal 1123 comes from a hardware switch 319. The hardware switch 319 has two banks, each bank having four output ports. To trigger a switch event, a bank and a data port must be selected, then a trigger pulse is sent.

The outputs of the PROM 1115 are a composite sync signal 1125 which is fed through a driving amplifier 1127, and the one bit video control signal 1208. The composite sync signal 1125 synchronizes the graphics board 303 to the rest of the video circuit 301.

The signal 1208 is control-led by the signal 1123. The signal 1208 has one of two values: video on, video off. When the signal 1123 is at a video off value the PROM 1115

selects the output of the video mixer 1201 for the time it takes a whole screen to be output from the combiner 315. When the signal 1123 is at a video on value the PROM 1115 selects the output of the player 305 for two-thirds of a screen and the output of the mixer 1201 for the other third. Thus the output of the graphics board 303 and pump 105 are always on the lower part of the screen while the upper part of the screen is selectable between the output of the board 303 and pump 105, and the output of the player 305.

RGB Monitor

An example of the display shown at the monitor 317 is given in figure 15. The_ top portion 1501 of the display shows the output of the player 305 or the mixer 1201 depending on the value of the control signal 1208. The bottom portion 1503 of the display always shows the output of the mixer 1201. AUDIO CIRCUIT

Reference will now be made to figure 4 in detailing the audio circuit 401. The PC 103 is connected to the player 305 as outlined in the description in the video circuit portion of this specification. The stereo outputs of the player 305 are fed to a four by two audio mixer 403. The other two inputs to the audio mixer 403 are not presently used but have the potential to accept computer generated voice and tone signals from the PC 103.

The output of the audio mixer 403 is fed into an audio amplifier 405. The output of the audio amplifier 405 is connected to an automatic ambient noise level feedback

circuit 407 whose output is then fed back into the input to the audio amplifier 405. The feedback circuit adjusts the gain on the audio amplifier 405 to compensate for changing background noise levels. For instance the gain of the amplifier 405 would be low during the quiet hours of the evening, while the gain would be relatively high during the noisy levels of the day.

The stereo output of the audio amplifier 405 is also fed to column speakers 409 and pump speakers 411. The microcomputer 103 has an output to the

hardware switch 319 as discussed previously. One of the outputs of the switch is capable of turning the column speakers 409 on and off, while another output of the switch

319 is capable of turning the pump speakers 411 on and off. TOUCH CIRCUIT

Reference will now be made to figure 5 in detailing the structure of the touch circuit 501. An output of the PC 103 is connected to touch electronics 503 which control a touch screen 505. The particular touch screen and touch electronics 505, 503 used in the preferred embodiment are manufactured by Microtouch. The touch screen 505 is an anolog capacitive glass sheet with a conductive coating bonded into its surface. The glass surface of the screen 505 is resistent to penetration by sharp objects. The glass construction provides for improved optical clarity. The touch screen 505 is placed over the red- green-blue monitor 317.

The touch electronics 503 measure the position of a capacitive coupling" caused by a finger or conductive

stylus touching the screen 505. The touch data, the position on the screen 505, is generated as an RS 232 signal and converted to current loop for transmission to the PC 103. The commands, responses, command formats, and response formats for the microtouch touch screen as used in the preferred embodiment are as follows: COMMAND/RESPONSE FORMATS

Each command is a string of ASCII characters consisting of the following: Header, Command, and Terminator. The first character (Header) in the command string is the ASCII Start-Of- Header character (ASCII 01 hex). This is followed by the command characters (capital letters, no blanks between characters). The last character (Terminator) in each command string is an ASCII carriage return (ASCII 0D hex). CONTROLLER FIRMWARE

A command is sent to the electronics 503 from the

PC 103 over the serial interface. After the electronics 503 executes a command, it returns a three character acknowledgment string to the PC 103. The string consists of a Header, the return code, and a Terminator, as follows:

•( " Header Code \ Terminator)' The return code is 0 (ASCII 30 hex) for successful completion or any number ranging from 1 to 9 (ASCII 31 hex) for failure. Table 1 lists command/response formats for mux/nonmultiplexed applications. Table 2 lists point formats in decimal.

-3b-

Table 1: COMMAND/RESPONSE FORMATS

TABLE 2: POINT FORMATS

DATA FORMATS

The X, Y data points sent by the electronics 503 to the PC 103 can be encoded in an ASCII format that represents a decimal format. In the decimal format, each touch point is sent as a string of 9 ASCII characters. Each x and Y value is sent as three characters. A Delimiter (ASCII comma), which separates the X and Y coordinates, is place between the Header and Terminator characters, as follows:

Header > X <Delimiter> Y <Terminator in decimal format, the coordinate values range from 000 to 999. OPERATING MODES

The electronics 503 has three modes of operation in decimal formats including:

-2T7-

Stream Mode -- In stream mode, the electronics 503 sends a continuous stream of data points to the PC 103 while a touch is held on the screen 505.

Point Mode — In point mode, the electronics 503 sends a single data point when a touch is applied to the screen 505. No data is sent while the touch is held or the screen 505.

Inactive Mode — In this mode, no data is sent to the PC 103 by the electronics 503. COMMANDS

RESET <H >R < T >

Set the electronics 503 operation to stream mode and the output data format to decimal; clears any points that are present in the output buffer; and runs a electronics 503 self-test routine.

FORMAT

<E >FH < T >

Selects the hexadecimal data format.

. MODE

<E > MS < T >

Sets stream mode.

<H > MP < T >

Sets point mode < H > MI < T >

Sets inactive mode.

-2-S-

CALIBRATION

< fH >CI < T> CALIBRATE INTERACTIVE

When you issue the interactive calibration command, the electronics 503 returns Header > 0 ζ. Terminator)*

The first touch is used by the electronics 503 to identify the lower-left corner of the display area. No point is sent by the electronics 503 for this touch, instead a <Η 1 (T> is sent to acknowledge the touch. The second touch is used by the electronics 503 to identify the upper-right corner of the display area. The electronics 503 returns a <H^0 T^ , indicating successful completion.

After calibration, the screen is set to Inactive mode. Issue a MODE command to set the desired mode. PAYMENT CIRCUIT

Reference will now be made to figure 6 in detailing the structure of the payment circuit 601.

The PC 103 has an output to a card note controller (CNT) 603. The three outputs of the CNT 603 run to a card reader 605, a note reader 607 and a receipt printer 609.

The CNT 603 processes all signals destined for the card and note readers 605, 607 and the receipt printer 609 from the PC 103. In the preferred embodiment an AutoTank CNT was employed.

The commands, responses, command formats and response formats for this particular CNT 603 include the following:

COMMAND DESCRIPTION A Note accepter control

B Beep speaker

C Card control

M Get card data

N Get note data

R Print to receipt printer The following sections describe the fields required for each of these commands. Each field is described individually; unless otherwise specified, all fields contain ASCII characters, i.e. a one byte ASCII field described as containing a 0 is represented by '30'H. The command/response itself immediately preceeds the data fields. NOTE ACCEPTOR CONTROL (A) code

code This one byte ASCII field describes the note acceptor control action:

0: eject note

1: accept and stack note

This command must be sent to the CNT for each bill " that has been inserted into the acceptor. BEEP SPEAKER (B) dur rep

I

dur This four byte ASCII field contains the duration of the speaker tone in 10 millisecond counts, i.e. for a 1 second tone, dur would contain 0100.

- θ - rep This one byte ASCII field contains a 0 for no repetition or a 1 for a repetitive cycling of the tone.

The beep command may be sent without any parameters, in which case default values of dur = 0025 and rep = 0 would be used. To turn off the beeper after a repetitive cycling has been commanded, send a duration of "0000". CARD CONTROL (C) code

code This one byte ASCII field describes the card control action:

0: eject card immediately GET CARD DATA (M) code

code This one byte field will contain individual track enable information as follows:

0: Read track 1, data sent in the clear.

2: Read track 2, data sent in the clear.

4: Read track 3, data sent in the clear.

Any or all tracks may be activated for any card read, however, at least one of the tracks must be enabled for the card to open the shutter. The initial condition is all tracks disabled. The card reader 605 will be disabled after a card is read, therefore, this command must be sent to the CNT 603 each time card data can be accepted by the PC 103. If there

- - is a card in the CNT 603 when this message is received, the specified track will be read and the data transmitted immediately; if there is no card, all card data commands received will be pending and will be executed when a card is inserted.

GET NOTE DATA (n)

The note acceptor 607 will allow all bills to be inserted after this command is received. The note acceptor 607 will be disabled after a note is inserted, therefore, this command must be sent to the CNT 603 each time note data can be accepted by the PC 103.PRINT TO RECEIPT PRINTER (R)

text This variable length field contains the ASCII text to be printed and all control characters. An automatic carriage return/line fee will be performed after each complete line (30 characters) has been printed.

The following control characters are supported:

OA'H: line feed

'OB'H: cliche stamp

OCH: cut receipt

'OH'H: carriage return (automatic line feed)

'OE'H: perforate receipt

CNT RESPONSES

COMMAND DESCRIPTION A Note accepter control response B Beep speaker response M Card data

-4α-

N Note data

R Receipt printer response

NOTE ACCEPTER CONTROL RESPONSE (A) status

status This one byte field will contain one of the status code as follows:

0 Note ejected 1 Note accepted and stacked N No note in acceptor S Stacker failure V Receive error T Transmit Error W Connect Error A Command to short L Command too long

BEEP SPEAKER RESPONSE status

status This one byte field will contain the following status code:

Command Accepted Command data too short Command data too long Non-numeric data

CARD CONTROL RESPONSE (C)

I status I

I. I

- i vl - status This one byte field will contain one of the status codes as follows:

0: Card removed

A: Command too short L: Command too long

N: No card in reader CARD DATA (M)

The card reader data message will be in one of the following formats: code card data

code This one byte field specifies the track which- was read.

0: Track 1 data sent in the clear 1: Track 1 data sent encrypted 2: Track 2 data sent in the clear

3 : Track 2 data sent encrypted 4: Track 3 data sent in the clear 5: Track 3 data sent encrypted E: Error reading Track 1 F: Error reading Track 2

G: Error reading Track 3 A: Command too short L: Command too long code data This field contains the data from the track specified in the code field. The length of unencrypted track 1 is 80 characters, the length of unencrypted track 2 is 40 characters and the length of unencrypted

-H- track 3 is 107 characters.

The CNT 603 will retry to read each enabled track for a total of three attempts; after which a read error message is sent. When the data is read from track 1, a 2OH is added to each character before transmission, data from tracks 2 and 3 have 3OH added before transmission. NOTE DATA (N) stat

stat This one byte field contains the current status of the note acceptor/stacker, The following values are possible:

$1 bill detected $5 bill detected $10 bill detected $20 bill detected note acceptor jammed connect error transmit error receive error note rejected

RECEIPT PRINTER RESPONSE (R) status

status This field contains a receipt printer status as follows:

Print operation completed Data field too short Printer busy, print request ignored

-i+5- D: Invalid data in text field

E: Printer error, print request ignored I: Low receipt paper, print request ignored L: Data field too long N: Text number not defined

FORMAT OF COMMANDS TO CNT 603:

STX CNT COMMAND CODE DATA ETX LRC FORMAT OF RESPONSES FROM CNT 603:

STX TERMINAL NO. CNT RESPONSE CODE DATA ETX LRC

The switch 319 is also a part of the payment circuit 601. The card reader, note reader, and print reader 605, 607, 609 are provided with lights 611, 613, 615 respectively. A further three outputs of the switch 319 are connected one to each of the lights 611, 613, 615. The use of the switch 319 allows these lights 611, 613, 615 to be turned on and off by the PC 103. KIOSK CIRCUIT

Reference will now be made to figure 7 in detailing the structure of the kiosk circuit 701.

The. microcomputer 103 is connected by a RS-232 line to a bulloch BT-9000 kiosk computer 703. Data communication is asynchronous at a baud rate 1200. Character length is 7 data bits with 2 stop bits and one even parity bit.

The kiosk computer 703 is .further connected to a host computer 705. The host computer 705 may be connected to other kiosk computers 703 in other locations to remotely capture point of sale information from many systems.

-Ac¬ credit cards may be credit authorized by the kiosk computer 703 over a phone line connected thereto. The computer 703 accepts and sends the following command response/request format, commands and responses/requests. COMMAND FORMAT

There are two formats for messages. The first format is simply an emulation of a subset of the pump 105 message set. For example, if the PC 103. wants to tell the computer 703 that it has a stolen credit card in its card reader 605, then it sends the STX format message "I HAVE A HOT CARD" to the computer 703.

If a message includes data, then the data is placed after the PUMP ID field and before the DEL (message terminator) . COMMANDS

TAKE PUMP FROM ME

The PC 103 is requesting the computer 703 to take over control of the emulated pump. This is normally done prior to a kiosk authorization request or kiosk transaction payment request.

No data. I HAVE A HOT CARD

The column is informing the computer 703 that it has a stolen card in its card reader 605. The PC 105 will not allow the card to be released until it 103 receives a "RELEASE CARD" request from the computer 703.

No data.

- 7- I NEED ATTENTION

The PC 103 is informing the computer 703 that it

103 has a system malfunction. A plain text description of the problem is sent in the data field of the message. The PC 103 will not resume processing transactions until it receives a "RESET YOURSELF PLEASE" request from the computer

703.

The data field contains the description of the problem. GIVE ME PUMP MAP

The PC 103 is requesting the computer 703 to send it 103 a pump map. A pump map describes the association of hose numbers to grade numbers. For example, Hose 1 could be either regular or super unleaded. No data.

HERE IS A TRANSACTION

The PC 103 is posting a PRE-PAY transaction to the computer 703.

The data field contains pump 105 D command data field appended with a 5 byte cash amount/authorization number field and a 2 byte response code field.

RESPONSES/REQUESTS

TAKE PUMP FROM ME

The computer 703 is releasing control of the emulated pump after either a kiosk authorization or the payment of a kiosk transaction.

No data.

- I N ¬ HERE IS PUMP MAP

The computer 703 is requesting the PC 103 to update the pump map of the PC 103.

The data field contains a 3 byte pump map. HERE IS TIMESTAMP

The computer 703 is requesting the PC 103 to update its time clock.

The data field contains a * 12 byte timestamp, YYMMDDHHMMSS. RESET YOURSELF PLEASE

The computer 703 is requesting that the pump 103 return to active service. This is normally sent subsequent to an "I NEED ATTENTION" request from the PC 103 to the computer 703. No data.

RELEASE CARD PLEASE

The computer 703 is requesting that the PC 103 release a stolen card from the reader 605. This is normally sent some time after the PC 103 has sent a "I HAVE A HOT CARD" request to the computer 703.

No data. CHANGE PRICES PLEASE

The computer 703 is requesting that the PC 103 commence a price change action. No data.

HALT PUMP PLEASE

The computer 703 is requesting that the PC 103 turn the pump 105 motors off.

No data.

STATUS

The computer 703 is polling the PC 103 for status. No data. DISPLAY DATA

The computer 703 is requesting the current pump 105 transaction data.

No data. AUTHORIZE

The computer 703 is requesting that the pump 105 be authorized. No data.

SET SALE COMPLETE

The computer 703 is requesting that the "SALE COMPLETE" bit of the pump 105 status message be set. No data. EXTERNAL SOURCE CIRCUIT

Reference will now be made to figure 8 which depicts the external source circuit 801. The PC 103 has an output connected to a modem 803.

The modem 803 . may be connected to any external device which supports communication by way of modem. In the preferred embodiment an external diagnostics computer 805 was connected to the modem 803. This computer 805 as its name suggests is used to monitor the proper operation of the PC 103 and the system 101, and to provide system software corrections. Equally, the modem 803 may be used to telephone a centralized credit data bank to authorize credit cards for monetary amounts.

-SO -

SET SALE COMPLETE

The computer 703 is requesting that the "SALE COMPLETE" bit of the pump 105 status message be set.

No data. SYSTEM SOFTWARE

The system software mentioned previously is annexed as schedule A to this description. The software is written in the C language for the QNX operating system running on a Tandy HD3000 microcomputer 103. # Referring to figure 13, the software implementation of the task structure will be discussed.

This operating system and language were chosen as the system may be required to operate unattended in potentially hazardous environments. The QNX operating system running in protected mode confines most software problems to the individual tasks. As well as adding to system reliability, the ability to prevent total system failure caused by software or hardware faults allows for remote diagnosis and remote software correction of problems. The tasks 1303 through 1325 communicate with one another to run the system. All tasks 1303 through 1325 begin operation when the PC 103 is powered up and run as long as power remains .

The tasks 1303 through 1325 fall into three categories: applications 1303, servers 1305 through 1315, workers 1316 through 1325. One application task ' 1303 is required to control any one system. Each PC 103 in the

-Si- preferred embodiment controls two systems, therefore the PC

103 will contain two application tasks 1303.

Servers and workers 1305 through 1325 provide services and work for the application tasks 1303. Therefore, the applications 1303 are often referred to as clients in the software. The applications 1303 are also referred to as DAVEs for reasons which are unimportant.

Workers 1316 through 1325 work for only one application (client) 1303. Servers 1305 through 1315 are capable of providing their services to . more than one application (client) 1303. Thus, for one PC 103 operating two systems only one instance of each server 1305 through

1315 exists. Servers 1305 through 1325 provide serial access to hardware and system resources which must be accessed by * more than one client 1203, but in a serial manner.

In operation the application 1303 requests an operation to take place by sending a request to a server or worker 1305 through 1325. The C language functions which accept these requests are contained in the /int sub-directory located after the main directory for each task.

WORKERS

The workers 1316 through 1325 do the following work:

BLINK:

Blink 1316 causes an introductory screen provided though the video circuit 307 to continuously switch from white to background colours and back again (blink) .

EVENT QUEUE : ~ ° L

The event queue task 1317 provides a serialized first in first out (FIFO) event queue to its application task (client) 1303. The event requests come from CNT, POS, pump, touch, dc9, and bulloch tasks 1307, 1311, 1319, 1321, 1323, 1325 as shown by arrows 1327. The event queue allows for asynchronous transfer of communications to the application task 1303 from the servers and workers 1305 through 1325. PUMP:

The pump task 1319 performs communications with the pump 105. TOUCH:

The touch task 1321 performs communications with the touch electronics 503. DC9:

The dc9 task 1323 performs communications with the laserdisk player 305. BULLOCH: The bulloch task 1325 performs communications with the kiosk computer 703. SERVERS:

The server tasks 1307 through 1315 provide the following services: CNT:

The CNT 1307 provides communication services to the CNT 603.

SWITCH :

The switch task 1309 provides serialized access to the hardware switch 319. POS: The POS task 1311 provides communication services to the host computer 705 via the kiosk computer 703. Sending of Point of Sale data to the centralized host computer 705. LOGGER: The logger task 1313 provides logging services to track the states of the various tasks 1303 through 1325. GRAPH:

If the video is in the graphics board 303 memory, it .is displayed via the graphics task 1315. If the video is in a disk of the player 305, the dc9 task 1313 is called. The transaction data from the pump 105 is always displayed via the hardware associated with the pump 105 in the video circuit 301. APPLICATIONS The application tasks 1303 steps through the steps of a sale transaction sending commands to the various servers and workers 1305 through 1325.

Some commands will take longer than a fraction of a second to respond to the command signal from the application task 1303 with the outcome. For the devices which take this longer period of time, their responses or requests to the application task are sent via the event queue task 1317.

This asynchronous process of command/response frees up the application task 1303 to respond immediately to an event generated by the customer.

Servers and workers 1305 through 1325 also provide timeout functions so that a command is responded to within a given amount of time whether or not the customer performs a specified action. OPERATION

The application task 1303 is passed a name and number, and the total number of application tasks 1303.

The application task 1303 initializes itself and then processes transactions. Initialization:

Initialization is passed the same arguments as the application task. .The task 1303 finds out which task it is from the arguments. The task 1303 calls the logger task

1313 logging the application 1303 status as start and printing the time in a log file.

The task 1303 checks to see that it is properly running within the operating system. The task 1303 sets up two records which will keep track of the current transaction and the previous transaction. The previous transaction record is important as regulatory bodies require transaction data to appear on the screen at all times and these records may be recalled to display the data. As well, the previous transactions record may be linked to determine past transaction data. A file is opened and zeroed where the transaction data will be kept track of. The previous tranaction record takes data from the data file.

The event queue -tsassk- 1317 is created. The number of the task 1317 is returned to the application task 1303. The task 1303 checks to see that the CNT, graphics, POS and switch tasks 1307, 1315, 1311, 1309 are running. The pump colour maps are brought in by the graphics task 1315. The touch zones are deactivated by the touch task 1321, a pump out of order screen is displayed via the graphics task 1315, and the touch zones are reactivated.

The video, card light, cash light and receipt light are turned off via the switch task 1209.

The blink task 1316 is created. The device ports for the player 305, touch electronics 503, pump 105, - and kiosk computer 703 are opened. The CNT task 1303 and POS task 1311 queues are started. The CNT 603 is reset. The application, task 1303 status is changed to ready by the logger task 1313.

This ends the initialization phase. Process Transactions:

The application task 1303 then processes transactions.

The task 1303 does a sale routine unless it encounters a transaction problem.

The sale routine resets all information and devices. First they cause the dc9 task 1323 to turn the player 305 show off (i.e. stop the disc presently in the player 305). Task 1303 switches the video off, both speakers off, and the column speaker back on via the switch task 1309. The current transaction record is cleared, the

-Sfc- grade pumped is set co the previous grade pumped, English is assumed, and the transaction sequence number is updated.

The task 1303 asks the pump 105 to identify itself via the pump task 1319. The bulloch task 1325 is checked to see if a price change has been requested. If so, it is performed by taking the prices from the kiosk computer 703 via the bulloch task 1325 and sending them to the pump task 1319.

The present prices are then read from the pump 105 to the task 1303 via the pump task 1319.

The time at which the prices were read is put into the current transaction record.

A language choice routine is then entered. The touch zones are deactivated, the language display, shown in figure 15, * is displayed and the touch zones are reactivated.

The English touch zone is that around "Touch here to start" while the French touch zone is around "Appuyez sur la touche". Other areas of the screen 505 are not touch sensitive. The transaction data of the previous tranaction i s displayed by the monitor 317 via the graphic task 1315.

The pump task 1319 is requested to report if pump goes out of service.

The display is set to blinking by the blink task 1316 and the graphics task 1315. The task 1303 then waits for an event. Either the screen 505 is touched, the prices are reset, or something happens to the pump 105.

If the screen 505 is touched it is determined whether the English or French section was chosen and the blinking is stopped. If one of the other events occurs an

-Si- Assuming a language has been chosen, a preset choices display is displayed in the chosen language and the touch zones are activated. figure 16 shows the preset choices display 1601 for the English language having preset

5 sections 1603. The areas around each preset section 1603, when touched, will send a signal representative of the preset amount. If the screen 505 is touched outside the preset sections 1603 the display 1601 will change to a

French display, not shown, as it is assumed the user does

10 not understand the language. The preset routine would then be entered again.

When a preset zone 1603 touched the amount is displayed in a preset box 1605 and the task 1303 is informed of the choice made.

15. If the screen 505 is not touched within a required time, the task 1303 returns to the beginning of the transaction process. The task 1303 assumes the customer has walked away.

If the customer has made a preset choice, a 0 payment routine is then entered and continues unless a problem occurs. The customer is asked whether he or she wishes to pay by cash or credit card. The display 1701 is shown in figure 17.

If paying by credit card the card touch section 5 1703 is touched. A card selection display 1801 is shown in figure 18.- Several cards may be used as shown in the display

1801. An audio prompt via the DC9 task 1323 informs the customer of the cards that may be used and requests that the customer to touch the screen on the intended card.

On selection of a card, the display changes to motion video with audio from the DC9 task 1323 showing the user which way to insert the card in the card reader 605.

With the card correctly inserted and read by the card reader 605, the customer is informed by an audio and video display, as shown in Figure 20, via the DC9 task 1323 that the card is being validated. The card is validated via the POS task 1311.

On validation, a motion video plus audio display, via the DC9 task 1323, requests the customer to remove the card from the card reader 605 and to proceed to fill the automobile with gas.

If the host. computer 705 via the kiosk computer 703 and the POS task 1311 is unable to.vali ' date the card, the card is returned and the customer is re-offered the card cash display 1701.

During the filling process, the customer is entertained with motion video and audio display from the player 305 via the DC9 task 1323 in the upper portion 1401 of the screen 505. Simultaneously, the transaction data is continuously displayed in the lower " portion of the screen 1403.

At the completion of the filling procedure, the pump 105 is asked whether its hook is down via the task 1303. If the hook is not down, a video and audio display is presented telling the customer to press the hook down. This ends the filling procedure.

A receipt request display is displayed asking the Customer if he or she requires a receipt. If a receipt is

- • < =- - required the display area is touched. A receipt is printed by the receipt printer 609 via the CNT task 1307.

Either after receipt is printed or a required amount of time has passed, a thank you video and audio display 1901, as shown in Figure 19, are displayed. The current transaction data is sent to the next previous transaction data record and is posted to the cheque file. The transaction information is then sent to the kiosk computer 703 via the POS task 1311. The application task 1303 is then logged sale complete in the log file.

If the credit card used by the customer is not one which may be read by the card reader 605 the customer after selecting this type of credit card on the card selection screen of Figure 18 is required to validate the card at the kiosk shown in Figure at the end of the fill procedure. The proceed to fill display is immediately shown with the additional words "please pay at the kiosk" and with an audio display advising the customer to pay at the kiosk when finished filling. The transaction now becomes a kiosk pay routine.

The pump 105 must be authorized by the kiosk computer 703 via the bulloch task 1325. The kiosk computer 703 then communicates with the pump 105 via the bulloch task 1325. When a hose is lifted from the pump 105 the kiosk computer 703 is notified. The kiosk computer 703 authorizes the pump 105. Again the motion video and audio displays entertain the customer during filling.

When the hook of the pump is pressed down the kiosk computer 703 is notified. The kiosk computer 703 takes the

-bo- transaction data from the pump 105. The bulloch task 1325 notifies the application task 1303 that the fill procedure is completed and the sale is logged sale complete in the log file. The customer is requested to pay at the kiosk by a video and audio display 2001, as s ' hown in Figure 20.

If the cash payment option on display 1701 was selected, the customer is shown a display on the manner in which notes may be inserted into the note reader 607. On acceptance of the first note inserted by the customer the display changes to an all cash in area 2103, and a window 2105 in which an accumulated total is displayed 2101, as shown in Figure 21, via the graph task 1315. An audio display via the DC9 task 1323 requests the customer to touch the all cash in area when the last note has been inserted into the note reader 607. As each note is inserted the window display 2105 is updated to reflect the total number of dollars entered by the customer.

When the all cash in area 2103 is touched an audio and video display via the DC9 task 1323 requests the user to select a hose and proceed to fill.

If the customer had preset the pump to a fixed amount at the preset choices stage, then when the cash inserted equals or exceeds the preset amount the proceed to fill display would automatically appear.

Again during the filling procedure the customer is shown a variety of video and audio displays while the transaction data is displayed on the lower portion 1403 of the screen.

- - " of -

When the filling procedure has been completed and the hook has been reset the receipt display is presented to the customer.

If at the completion of the transaction cash totalling an amount larger than the value of gasoline dispensed has been inserted, a receipt and refund display 2201, as shown in Figure 22, is displayed. A window 2203 in the display 2201 shows the amount of refund due to the customer. An audio display advises the customer to obtain a receipt by touching a print receipt display area 2205 and to take the receipt to the kiosk for a refund.

The thank you display 1901 is shown after the receipt is printed or a required amount of time has passed. The current transaction data is sent to the next previous transaction data record and is posted to the cheque file. The transaction information is then sent to the kiosk computer 703 via the POS task 1311. The application task 1303 is then logged sale complete in the log file. COMMAND FILES The command files which set the device terminals for communication between the hardware 101 and the software are appended to this description as schedule B. The command files determine the parameters for communication transfer and the terminal at which transfer is to occur. The command files also use the utility program Load-frame to down load the graphics specifications for the various displays to the memory of the graphics board 303.

While the present invention has been disclosed in connection with the preferred embodiment thereof it should

-ki¬ be understood that there may be other embodiments which fall within the spirit and scope of the invention as defined by the following claims.

SCHEDULE A dave/request.h ^define MAX_STRING_DATA 150

typedef struct { unsigned opcode; unsigned client; unsigned value1 ; unsigned value2; unsigned value3; unsigned value4; unsigned value5; unsigned valueβ; char string_data [ MAX_STRING_DATA ] ; } request;

" ^define REPLY (t-b) reply (t,b,sizeof(*b) ) " ^define SEND (t,b) send(t,b,b sizeof(*b) " ^define RECEIVE_ANY(b) receive (0 ,b ,sizeof(* ) ) ^define RECEIVE(t,b) receive(t,b,sizeof(*b) ) ^define CRECEIVE(t,b) creceive(t,b,sizeof , (*b) ) =#define COPY_SAFELY(a,b) strncpy(a,b,sizeof(a) )

DIRECTORY level: 3 — bulloch/int/bull_int.o ' bull cmd

bullochs_id give_me_puπ_p_map give_me_timestamp ere_is_a_transaction. i_h c _.ve_a_hot_card i_need_attention kios _authorize kiosk_payment opeή_bulloch price_change_completed dc9/int/audios.o all__cash_in_audio announce_audio bad_card_audio bad_note_audio both_readers_down_audio cancelled_card_audio cancelled_cash_audio card_abend_audio card_aut____audio card_choice_audio card_reader_down_audio cash_abend_audio declined_card_audio hot_card_audio kiosk_alerted_audio kiosk_halt_audio note_reader_down_audio other_card_audio out_of_service_audio pay_choice_audio petro_card_audio printer_dead_audio pump_raoney_audio pump_number_audio pump_or_else_audio

receipt_credit_audio receipt_no_credit_audio reraove_σard_audio replace_nozzle__audio replace__your_card_audio system_ i _down_audio dc9/int/videos.o card_auth_video fill_video goodbye_thanks_video insert_bill_video insert_card_video lift_and_pay_at_kiosk_video lift__nozzle_video longer_card_auth_video remove_card_video events/int/bulloch_event.o bulloch_event events/int/card_event.o card_event events/int/cnt_eve t.o cnt_event events/int/control_event.o control_event events/int/get_event.o get_event events/int/note_event.o note_event events/int/player_status.o player_status__event events/int/pos__event.o pos_event events/int/power_event.o po er_event events/int/price_event.o price-event

events/int/print event.o print_event events/int/pump_event.o puπ_p_event event s / in t / show_over . o sho _over_event events/int/stack_event.o stack_event events/int/touch_event.o touch_event events/int/touch_status.o touch_status_event events/int/vseek_event.o video_seek_event logger/int/log_2260.o log_2260 logger/int/log_bulloch.o log bulloch. logger/int/log_dave.o log_dave logger/int/log_eq.o log_eq logger/int/log_pos.o log pos logger/int_power.o

Log_power logger/int/log_ )ump.o log_pump logger/int/log_touch.o log_touch logger/int/log_video.o log_video logger/int/relog.o relog logger/int/stop_log.o stop logger

newpos/int/admin_int.o pos_admin-cmd pos_delete_fit_record pos_die pos_give__me_a_fit_record pos_give__me_your_info pos_give-queue_entry pos_load_fit pos__load__info pos_probe pos_reset_stats pps_set_link_timeout newpos/int/pos_int.o open_pos_server pos_active pos__authorize_card pos_capture_transaction pos_cmd pos_decode_card pos_server_alive pos_whats_cards_date pos_whats_header_1 switch/int/audio.o audio_1_on audio_2__on switch/int/genlock.o clear_genlock_trigger set_genlock_trigger switch/int/lights.o card_light_off card_light_on cash_light_off cash_light_on reσeipt_light_off receipt_light_on switch server alive

switch/int/speakers.o both_speakers_off both__speakers_on coluι_.n_speaker_off colu_nn_speaker_pn pump_speaker_off pump_speaker_on switch/int/speakers.o both_speakers__off both_speakers_on column_speaker_off colunm_^speaker_pn pump_speaker_off pump_speaker_on switch/int/video.o video_off video on

level:- 2 blink/int/blink__int.o blink_off blink_ n start_blinker bulloch/int/bull1_int.o load_pump_total cnt/int/cnt_int/o cnt_beep cnt_clear_timer cnt_cmd cnt_server_alive open_cnt dc9/int/intl.o open_video_player player_status_request prequest stop__video_show

events/int/equeue_id.o event_queue_id events/int/event.o event graph/int/graph_int.o display_card_type display_cash_in display_cash_in__low display_clear_prepay display_credit display_frame . display_grade display_preset . display_preset_label display_prices display_pump_number display_string display_string_centered display_system_cancel_credit display_transaction_type display_user__cancel__credit graphics_ram_usage graphics__server_alive load_bits load_frame open_screen open_screen_warm graph/int/graph_int2.o display_arrow display_init__arrow display_reset_arrow logger/int/1request.o

1request misσ/blastrow.o blastrow newpos/int/power_int.o

pos_disable_transmissions pos_enable_transmissions pos_save_data newpos/int/po er_int.o pos_disable_transmissions pos_enable_transmissions pos_save_data pump/int/pump_int.o authorize_pump open_pump pump_change_prices pump_fi11ing_data_request pump_go_native pump_go_touchcom pump_halt_now pump_hose_filled pump_hose_selected pump_hose_totals_request pump_id_request pump_is_hook_down pump_is_hook_down_now pump preset request pump prices request pump_ready_for_fi11 pump_restart_now pump_status_request quiet_pump report_pump_out_of_service set_pump_sale__complete switch/int/int2.o srequest touch/int/touch_int.o activate_touchscreen clear_touch_zones deactivate_touchscreen define touch zone

open_touchscreen touch_status_request level: 1 events/int/start_queue.o <equeue_id> start__event_queue misc/address.o

Address_of misc/cal.o -calcsecs calerr caljoin calmthlen calnow calnwork calsplit caltimezone calwkday misc/daves_name.o daves_name misc/disallow.o disallow misc/dr.o '<dr> misc/fatou.o fatol fatou misc/movebytes.o movebytes misc/movedata.o movedata misc/my_ds.o my_ds misc/my_ope .o my_open misc/print_ctrl.o print_ctrl

-11- -

/user/steve/tools/εelec .

/* utility to generate 286 selectors */

main (argc, argv) int arqc;

unsigned segment, o-Ftset, limit, mask, selector;

i-F ( argc <= 5 ) usage () ; else

segment = atoh (argvLll ) o -Fset = atoh(argvE23) j lin.it = atoh CargvC33> ; mask = atoh (argvC4_l ) ; selector = create_seg ( offset, segment, limit, mask ); printf ( "real address 04c :"yC04x limit "Λ04κ mask '/Λv_ selector %κ\n"„ segment, offset, limit, mask, sele or 5;

usage ( )

printf . "select hiθ lowlώ limit mask\n" );

- * 7<+-

appl/card_pay.c #include "screens.h"

#include "vars.h"

#include "exceptions.h"

nclude <stdio.h>

Card_ρaymen ( ) r w int et; char *e; unsigned event_mask;

if ( pos_active< dave ) == 0 ) /* can't validate any */ longjrnp . post_pay_trap, PD3_INACTIVE ); /* cards now*

while ( (et — Type_o _card_choi e ( ) ) == 2) /*petro reset Ioo

if ( et == 0 ) return 0;

car d_l i qht_ on ( dave ) ; if ( i card_reader_armed ( ) ) arm_.card_reader ( 60 ) ; Set_user_entry < insert__card_video ( T— >language ) );

event_mask = VIDEO_SEEK_EVENT ! CARD__EVENT !

ΞCREEN_TOUCHED ! SH0 _0VER; while (et = new event ( _.e , event mask 3)

- -1S -

swi tch . et )

C case SHOW_OVER: video_off( dave ); break; case IDE0_3EE _EVENT: show , sc een . davb, _Ni_.Lr.. __C I-I'_>__-3L.Π , E N > :; break; case SCREEN_TOUCHEDs /* user has cancelled */

video__off ( dave ) ; stop_vi eα_sho < ); cnt_clear_timer . dave ); card_i iqht_of ( dave ) ; 3et_user_exit ( ) ; return υ; default: /* a CARD event */ Set_user_e.'it ( ); switc ( *e )

case 'C ' 5 break_ /*ιqnorρ eject responses)*-/ case ' Z ' : case 'M ' s switch (e C 1 3)

C_.S£ ' ' ' _

J onπ -imp ( tt- .ιυ„ .JIT-.T RESCT M ?

— lb-

break; case '2': COPY_SAFE Y( T->card_n umber , e + 2 ); T— >card_type = pos_decode_card ( dave, e + 2 ); if ( T->card_type — BAD_DATE_CARD )

T—>response_codeC 0 _. = '5';

T—>resραnse_codeL 1 _ = * 4'f,

_* else if ( Card_tyρe_iε_.known_to_me ( T->card_type ) ) goto captured; longjrr.p . post_pay_trap, CARD_REFUSED_POS > break; case 'F's Card_read_f i lure ( > break; default: longjmp ( transaction_traρ , CANT__READ_CARD ); break;

/* end of card switch "• *-/ /* end of event swi ch #/ C * end of while * / capturedΪ display_card_type< dave, T->card_type >

Validate_card ( ); Eject_card ( ) ; return 1;

-11 -

Card_type_is_known_to_me ( type > unsigned type; r

return type != UNKNOWN ^ CARD;

. char -*e; εhow_screen < dave, BAD_CARD_SCREEN > cnt_cmd . dave, "CO", 0 ); /* spit it out */ vιdeo_off ( dave > bad_card_audιo( T-.-language ); /* tell the user */ r,e _event . _.e, CARD_EVENT . ; / * ws.t for removal */ e++; ii f & e ' = ' O ' ?.,?/ t-e ' = ' ' . longjmp ( transactιon_trap , CANT_READ_CARD > ; arm card reader < 30 > ; /* " let user retry */

char *e; unsigned et, shows_played = t card_val i dated = 0;

I T . ppsi . authoriie card ( dave, T— n> * "esr>t_ amount ,

T- c.r nuι τ ιL'6_. . ~--~ •■ , ; | I J imu ( po-"' u _■ __tι ΉJ

— -7 -

CARD_REFUSED_POS > ; show_screen( dave, STANDBY_AUTH_SCREEN ); stop_video_sho ( > video_o f ( dave ) ; card_auth_audio( T->languaqe > while ( et = new event. _.e, SHOW OVER ! POS EVENT

switch ( et )

case SHOW_OVER: shows_pl yed++;

if ( shows_played == 1 ) /* audio is over */ card_auth_video( T->language ); if < shσws_ρlayed =-= 2 ) r •. if ( card_validated ) return; else longer_card_auth_video( T—/language > s

break; case PDS_EVENTΪ memcpy( T->auth_number, e + 9, 5 ); memcpy( T—>response_code, e + 14, 2 ); T—>language_code = eC 1 3; if ( memcmp( e, "HOTCARD"-, 7 ) == O ) hot card ( ) s

else if ( me cmp < e, "POSTPAY" , 7 ) == 0 ) longjmp < post_pay_tra , CARD_REFUSED_POS ); else if ( memcmp < e, "VALIDATED", 9 ') == 0 ) if ( shows_played >= 2 ) /* first video is over */ return; card_val idated = 1;

else longjmp ( post_pay_trap , CARD_REFUSED__POS ); break;

Eject_card ( )

char -*e .

-*get_pumρ_event . ) , response; unsigned c a r d r e m o ved = 0 , show_over = 0; cnt_cmd ( dave, "CO", 0 ); cnt_beep . dave ) ; show_εcreen ( dave, REMOVE_CARD_SCREEN > r e m o v __ c a r d _ v i d e o ( T - > 1 n q u a qe ) ; while. 1 )

-so -

et = new_event < 8<e, CARD_EVENT ! SHOW_OVER ) ; response = eC 1 3; if < et == SHDW_OVER ) r u show_over = 1; i f . card_rernoved ) return ; el se

vi deo of f < dave ) :

el se switch ( response )

case O'_ card_light_of ( dave ) % card_removed = 1; pump_is_hook_down_no ( ); if ( Equal_buffers( get_ρumρ_even ( ) , "HOOKUP", 6 ) ) return; if ( show_over ) return; break; default : longjmp ( transaction_trap , CANT_EJECT_CARD ); break;;

- S I -

static unsigned reader_armed; arm_card_reader ( seconds ) unsigned seconds; r

cπt__c_τϊd ( ve "M2" < seconds .>

reader ^ armed = 1;

-.

Di sarm_card_reader ( >

reader_armed = 0;

card reader armed ( )

return reader armed;

-S2_-

appl/cash_pay.c

♦.include "screens.h" #include "vars.h" #include "exceptions,h"

#include <stdio.h>

static jmρ_bu.f _dough,

*too_much_dough; static int all_cash_in_visible;

#define FETRO_LIMIT

#define PRESET_AMOUNT_EXCEEDED

static int note_read, cash_iπ_state;

ttdefiπe FIRST_NOTE 0 #define NEXT_NOTE 1 #define STACK 2

#define LAST STACK 3

L.ash_payment ( )

char *e;

if < setjmp ( too_much_dough ) ) /* say something ? */ else

al 1 cash in v _ sib e = 0_

-»-

cash_in_state = FIRST_NOTE; cash_l ight_on ( dave ); insert_bill_video( T- language > new_event< ...a, VIDEO_SEEK_EVENT ); show_screen < dave, INSERT_BILL_SCREEN > j -r ! riote_readei-_srii-ed . ) ) ar _note_re ad er ( 60 ) ; more_noteε< ) ;

if (T->cents_in > 0) /•* user may have cancelled */

if .T-.-preset_amoL.nt :■ T->cents_in)

/-* preset for Ϊ5.00, but only * T- .-preset , amount = T- -ceπts__in; ' * put in -T2. 0, eg.*/ if (T->preset_amount == 0) /* it's a fill */

T->preset_.amσunt = T->cents_in; displ ay_preset_l abel (dave , T-M anquage, T- •• preset_amount );

__ cash_light_of ( dave ); return T-;-cents_in ■ O; /* user may have cancelled *-/

/************************************************/ /* */

/* EVENT HANDLERS */

/******* J--***** i^********** ************* *******^,' o '. e )

char *e;

return 1 ;

kv( e ) /* video event handler */ char *e; r ι_ video_off ( dave ) ; return 1;

first_not_e( e ) /* waiting for very first note */ char *e; r

char response = EC 1 3;

switch ( response )

£ case CNT_TIMEDUT: /* user never tendered */ longjmp ( traπsactioπ_traρ , JUST_RESET_ME ); break; case 'R': bad_note_error ( ); /* note read and rejected *-/

return 1; break; def ults if . iisdigit( response > > •- " -£ device error *■ /

-SS-

brea ;

note_read = response; /* remember it */ cnt_cmd< dave, "Al", 30 ); /* try to stack it */ cash_ιn_state = STAC!- ; return 1;

stac. < e ) /* cnt has replied to a "stac. " command */ char *e; \ r. if ( * e == CNT_TIMEDUT ) /-* device error */ longjmp ( transactιon_tra , STACI.ER_F ILURE ) ;

B++ ;

case '0': bad_note_error ( ); /-*stac. er ejected it*/ cash_ιn_state = NEXT_NCTE; return 1; case 'I's brea. ; default: longjmp ( transaction_tra ,

STAC. ER_FAILURE ) ; break;

M" ill nu I •ri cl fc i' I n

/- O > ft >r c-inc not e — no ' ι _ "'ec' i .-I

-Sfe-

cash_in_state = NEXT_N0TE; accumulate_funds( note_read ); return 1;

ιck_last( e ) - cnt has re char *e;

if ( *e == CNT_TIMEOUT ) /* device error */ longjmp ( transact!on_trap, 3TAC ER_FAILURE );

e+t-; if ( *e == '0' ) /* stacker ejected it */ retLirn O; else if ( -*e != '1' ) /* device error */ longjmp ( transact! on_traρ , STACKER_FAILUF:E );

accLimul te_f unds ( note_read ); return 0; /# all done */

/* cnt has replied to the next "read note" command */ char *e;

,r

char response = eC 1 3;

-=- w i ii h r~ ~ 5S! on ss - :

- pl¬

ease CNT_TIMEOUTs /* logic problem */ longjmp < transaction__trap, CANT_READ_NOTE );

break; case 'R': bad_note_error ( ); # read and rejected */ return 1; break; def ult: if . lisdigit. response )) /* device error */ longjmp ( transact!on_trap , CANT_READ_NOTE > break;

note_read = response; /* r ιTιe b r it */ cnt_cmd < dave, "Al", 30 ); /* try to stack it */ cash_in_state = STACK; return 1 ;

touched ( e ) /* screen has been touched or timed out *. char *e;

cnt_clear_timer < dave ); switch , cash in state )

:ase STACK;:

cash_in_state = LAST_STAC ; return 1; break; case FIRST_NOTE: i ( #e = 'R' ) return O; el e longjmp transact!oπ_trap, JUST_RESET_ME ); return 1; /* to be consistent */ break; case NEXT_N0TE: return 0; break;

static PFI stable C 4 _1 C 4 3 = -C

/* Inputs Touch Note Reader Stacker Video */ toLtched , first_πote, nop, kv, /* awaiting first note */ touched, na.-.t_nαte, nop, kv, /* awaiting next note #/ touched, nop, stack, kv, /* awaiting stack or touch */ nop, nop, stack_last, kv /* awaiting last stack */

more note ' s ( )

hctr *e 5

- s*. -

PFI handler; unsigned my_events = SCREEN_TDUCHED i * SHO _DVER I NOTE_EVENT ! STACK_EVENT;

for (; ; ) r

switch < new_event < S.e, my_events ) ) _ case SCREEN_TOUCHED_ col = 0; break; case NOTE_EVENT: col = 1; break; case STACK_EVENT: col = 2; break; case SH0W_0VER: col = 3; break;

•\

handler = stable C cash_in_state II C col ; if ( (*handler) <e) == 0 ) return;

static unsigned note_values CD = -C 100, 200, 500, 1000, 2000 ;

/* call this function if and only if a note */ it /* has been successfully READ and STACKED */

accumul te_funds ( note ) int note;

T-~>cents in -ι-= note v lues n 11_> •_ tr.' -~ .1.

display_cash_in_low< dave, T->cents_in );

if <T->cents_in >= MAX_CENTS_IN. longjmp( too_much_dough, PETRD_LIMIT ); if (T— cents_in >= T—>preset_amount _.S. T->preset_amoLiπt != 0) longjmp ( too_much_dough, PRESET_AMOUNT_EXCEEDED );

if ( ali_cash_in_vi ible == O > r ι_ video_of f ( dave ) ; stoρ_video_sho < ) ; show_screen( dave, ALL_CASH_IN_SCREEN > all_cash_iπ_audio ( T— ^language ); all_cash_iπ_visible = 1; disρl y_preset ( dave, T->preset_amourιt , T->languaqe )

display_cash_in ( dave, T—>cents_in );

bad note error ( )

vid«=.o_off ( dave ) j. stop_video_show ( ); show_screen ( dave, BAD_NOTE_SCREEN ) ; all_cash_in_visible = 0; bad_note_aLidio < T- .--language ) ; ar _note reader ( 0 > s /* let the user retry -s-./

static unsigned _reader_armed;

* arm_note_reader < seconds ) unsigned seconds;

.r cnt_cmd ( dave, "M" , seconds ) ; reader armed = 1;

Disarm note reader . )

_reader_armed = ;

note reader armed ( )

return reader armed;

-qi -

appl/c iles card_pay.c blink.c cash_pay»c checkpoint.c dave. c decode_ρu * π . c l ogger. c ρost_pay . c price_change.c hot_card. c device_error. c disp_prev. c equal__buf.c fillerup.c send_headers.c learning. c getpu peveπ . c recei pt_f o a . c l ob l s. c __fc_ i c _i .y .. ι __.

do_a_fi11. c headers.c new_event.c preset_choices. c prin _car. c print cπt.c

print_refund.c print_docu.c * * print_receipt.c proceed_ i11.c process.c screens. seiect_grade.c strings.c tri . c type_of_card.c type_of_pet.c video_receip .c wash_choices. c

appl/checkpoint. c "^include <stdio.h> "trans .h" ifc Lnclude " checkpoint. h"

static FILE *cheσk_file ;

static cpoint check;

Open_checkpoint ( dave ) ^ _ unsigned dave;

{ char checkpoint_file_naι__e [ 30 ] ;

tsp in f(checkpoint_file_narae, ,l /dave/dave%dcheck", dave) ; check_file = fopen (checkpoint_file_name, "rwv") ; zero (Scheck, sizeof (check), check_file) ;

} Store_checkpoint( dirty ) unsigned dirty; { check.c_dirty = dirty; tput (&check, sizeof (check), check_file); fflush (check file); fseek (check_file,OL,0): }

Restore previous transaction( t ) transaction *t; { *t =check.previous; } Restore__current_transaction( t ) transaction *t; { *t = check.current; }

Close__checkpoint ( ) { fclose( check_file) ;

}

Push_checkpoin ( )

{ check. revious = check-current; zero( Scheck.current, sizeof( transaction )); check.c_kiosk__mode = 0; check.c_filling = 0; check.c_printing = 0;

Store_cheσkpoint ( 0 )

}

Checkpoint (t ) transaction *t;

} check.current = *t;

Store__checkpoint( 1 ); } Dirty_checkpoint( )

{ return check.c_dirty;

}

Checkpoint kiosk mode( t ) transaction *t;

{ check.c_kiosk_mode = 1 ;

appl/checkpoint.e ^inclu e <stdio.h> - include "trans.h" "-^ include "checkpoint.h"

static FILE *check_file;

static cpoint check;

Open_checkpoint ( dave ) unsigned dave; { char cheσkpoint_file_name [ 30 ];

tsprintf(checkpoint_file_name,"/dave/dave%dcheck", dave) ; check_file = fopen (checkpoint_file_name, "r v"); zero (&check, sizeof (check)); zero (Scheck, sizeof (check), check_.file) ; }

Store__checkpoint( dirty ) unsigned dirty; { check.c_dirty = dirty; tput (&check, sizeof (check), check_file); fflush (check file); fseek (check_file,OL,0):

}

Restore previous transaction( t ) transaction *t; { *t =check.previous; }

Restore_current__transaction( t ) transaction *t; {

*t = check.current; }

Close_checkpoint( ) { fclose(cheσk_file) ; } Push_checkpoint( ) {

check.previous = check-current; zero( &check.current, sizeof( transaction )); check.c__kiosk_mode = 0; 5 check.c_filling = 0 check.c_printing = 0 Store_checkpoint ( 0 ) }

Checkpoint (t ) 10 transaction *t;

{ check.current = *t; Store_checkpoint( 1 ); } 15 Dirty_checkpoint( )

{ return check.c_dirty;

}

Checkpoint kiosk mode( t ) 20 transaction *t;

{ check.c_kiosk__mode = 1 ;

Checkpoint( t );

25

• _

appl/checkpoint. typedef struct -C unsigned c_dirty, c_kios.c_mode, c__filling, c_printiπg; transaction current, previous; cpoint;

appl/dave.c #iπclude "device. " #include "vars.h" #include <stdio.h> #include "screens, h"

iTiaiπ v a « a . int argc; char -*argvC3;

,r

Initialise, argc, argv ); Process transactions. );

Initialize, c, v ) int c; char *vC3;

unsigned my . _events; char *e, logm C 60 3 ,

*daves._name . ) ;

if . c != 2 _.& c != 3 ) usage (> ;

debug_event = c = * = 3;

at i Cv L 1

if ( dave <= 0 ! dave > NDAVES ) usage <) ;

log_me. "start" );

if ( register_name< 0, daves_name . dave ) , 0 > i= ) i. tsprintf ( logm,, "can't register 7.ε" , daves_name( dave ) . ; if (debug_event> tfprintf( stder , "y.sXn", logm ); log_me . logm ) ; exit ( ) ;

T = £._curren ; P = S._previαus;

Open_checkpoint ( dave ); Restore_previous_transaction ( P );

my_events = start_event_queue( > if (debug_eve_πt) tfprintf( stderr, "Hi dave\n" );

Check_servers( ); open_screen_war < dave ); s ow_screen ( dave, PUMP_OUT_OF_ORDER_SCREEN ); video_off ( dave ); card_light_off ( dave ); cash light o ( dave ) ;

-\o\ -

receipt_light_o ( dave );

start_blinker . dave ); αpen_my_devices( dave, my_events ); Reset_the_cnt ( > ;

log me ( "ready" );

Check servers (>

extern int cnt_server_alive (> , graphics_server_alive () , poΞ_server_alive <) , switch_server_alive ();

Check_server (cnt_.server_alive, "cnt server" );

Check_server <graphics_server_alive, "graphics server" );

Check_server (switch_εerver_al ive, "switch server" );

Check_server (pos_server_al ive, "pos_server") ;

Check_server (fen, message) r _ int (*fcn) () ; char *message;

int task alive; ch r loqffi C. ώO 3;

i f < (task_al i ve = (*f cn ) ( ) ) ~= 0 )

,r w tsprintf ( logm, "can't find V.s", message); if <debug_eveπt) tfprintf (stderr, ""/.s\π", logm); log_me( logm ) ; exit ( ) ;

open_my_devices( d, myqueue ) unsigned d, myqueue;

,r

dave_device *dv;

d—; dv = devices + d; open_video_player ( dv->video_port, myqueue, d + 1 , 1 ); open_touchscreen ( dv—>touch_pαrt, myqueue ); open_pump( dv—>pump_por , myqueue > open_bulloch ( d + 1 , dv—>bulloch_port > oρen_cnt( d + 1 ) ; open_pαs_server ( dave ) ;

usage( )

tforiπtf ( stder "dave : -dave nu ber L1 or d\n'

ex i t ( 0 ) :

* Reset_the_cnt ( )

char *-e ;

cnt_c d ( dave, "H" , .!.0 ) ; new_event( 8.e, CNT EVENT ); cnt_beeρ ( dave > ;

a

— )© + -

appl/dave.map .Segment: 1 OOOO to 7344 (29509 bytes) .Segments2 OOOO to 0D2E (3375 bytes) -Segment.3 0D2F to 186C (2S78 bytes) •Total size is SBB2 (35762) bytes

C 1 0053 prologue

COi 005E epi1ogue

CO1 0067 stk_over 1ow

CO! 007D <exit>

C01 00S3 Φucbeg

C01 0084 <Card_payment>

C01 0273 <Card_type_is_known_to_me

C 1 028F <Card read -failure)-

C01 04A6 <Eject_card>

COi 05C2 <Disarm_card_reader>

C01 05D2 <card_reader_ar ed>

CO1 05E1 <Set_b1ink_on>

COI 05F4 <Set_blin _off>

COi . 0607 <Blinking>

COI 06lό <Cash_payιTιent>

C01 0722 <nop>

C01 0731 <kv>

CO1 07 A <first_note>

COI 07D7 <st ck>

-\σS-

COl 0942 --".touched>

COI 09A8 ''more^otes ' ' - OI 0A22 .accumulate^unds -

COI OBOD -.bad_note_error> OI 0B52 arm_note_reader

COI 0B77 Disarm note reader

COL OB&: rι JLt__r «acifc , r_arr * .t_- ι

COI 0B92 Open_chec. point

COI OBDE Store_chec.'poιnt cυi 0C20 Restore_prevιous_transac 1on

COI 0C3B - Restore_current_transactιon - COI 0C56 "Close_checkpoιnt , OI 0C6A Push_chec. point C I OCBO Chec. point COI 0CD5 D- rtv_chec. poi t COI 0CE4 Checkpoint_. ιos. _mode ecu OCFD ain

COL 0E7P- Lhec. _servers

CO] OECi Chec . _ser vmr

Cυi OF17 o en_πιy_d v i ces OI 0F9D usage

COi OFBF Reset_the_cnt -

COI 0FF3 decode_pπ ces -

CO1 105E decode_grade

C01 lυsF decouϋ _ f : 1 I _ tci

Ol J OD< , Lyρr_'"J_ i x I ι i nπ . dat..

— lθb-

C01 1155 hose_of>

COI 1195 <Cash_price_o >

COI 11E5 <Initiali2e_pun.p_.nap

COI 1277 <Device_erro >

COI 135F <display_previous_transaction:

COI 13DB <Equal_bu ers>

C 1 1400 <Fill_er_u >

COI 14FE <Reset_kiosk_halt>

COl 150E <K!αsk_halted_us>

■ OI 1553 <Kiosk_restarted_us>

COI 15AA <delay>

CO1 15C5 <hot_card>

COI 1674 <log_me>

COi 169D <Do_a_fi11 >

COI lόSA <Post_pay_fill_iπtro>

COl 17C5 <Post_pay_end_of_fill >

COI 18SE <C1ear_kiosk_authorina ion>

COI 1B9E Set_kiosk_authorization>

COi 13AE <Kiosk_has_authori2ed>

COI 1SBE> < ait_show_over_and_auth>

COI 1911 <Card_has_been_refused>

COl 1A39 <price_change>

COI 1A6C <price_data>

CO! 1A7B <price_change_requested>

COI 1ASA <pri e_change_done>

COl 1 A3

COI 1AC9 Set_ussr_entry>

COI 1AFO Set_user_e>sit

COI 1B14 <User_needs_help>

COI 1B2D <User_speed_factor>

COI lBόό <get_pump_even >

COI 1B --:set_rec_;inf_ header1..

COI 1C27 :.cnt_strιng

COI 1C3F -.dollars.-

COI 1C7F <cnt_te;;t>

COI 1C9F <Ξet_document_language

COI 1CAF format_header

COI 1D56 <format_fill_data>

COI 1DFF <cnts_grade.-

COt 1E4C -::tormat_card_t_nder.: :

Cυi 1E77 ■__ ormat_fuel '•

COI 1EB4 <for.τ,at_total ..-

COI 1EF1 <.format_cash_tender!

COI 1F2E 'fo at_change_due..

CO. 1F74 - ' e.iect _and perf rate -

COL 1F99 eject_and_cut

C 0 J 206 C ϊqct -Bcei p t _ h e a α er =

COI 20A3 <header1 ' :•

COI 20B2 -'Send_cnt_headers>

COI 2109 <Cnt_ram_reset ' --

COI 2119 Set._cnt_raιn_loaded-

I--J ] —.1. -7 l I _ r -UH _•-'I-

C' i " __J70 n__ ι_,".--rιι

- \0^ "

COI 221D <process_control_event>

COI 2234 <event_success_code>

COI 2243 Unwanted_event>

COI 229A <Process_po er_event>

COI 22C8 <Update_timest mp>

COI 22F4 <Preset_chαices>

COi 23EC <print_car_wash_voucher>

COI 23F6 <print_cnt>

COI 246B <Pri t_credit_voucher>

COl 2485 <Print_documents>

COI 254F <binauth>

COI 257E <Print_receipt>

CO1 2όCA <Proceed_to_fi11 >

CO1 299F <Prαcess_transac ions>

COI 29DD <Process_eκcaption>

COI 2A83 Do_oπe_sale>

COI 2B32 <Reset_all>

COI 2C37 <Laπguage_choice>

Cul 2CEA <Lanquage_≥crsen_tϋuch>

COi 2BS3 <Pay er.t_loop>

CO! 2DCC <Pay_choices>

COl 2E76 <calculate_totals>

COl 2F13 <Make_sure_the_hook_is_down>

COI 2F7ώ <Pre_pay_transaction_outcorr.es;

COI 2FB0 <Receipt>

COI ώ t. __receipt

COl 30CE <System_cancel_receipt> COI 3165 <Receipt_graphics> COI 31CA <thank_you>

COI 31F9 <save_previous_transaction> COI 3218 <post_transaction COI 3300 .packed_auth_langι.ιage ': - .1 og_trcine,actloiι Powe _has_failed.: -:set_screen_ti eout '; .reactlvate_language_touchzones. COI 340A :.show_screen_alone> COI 344C <show_screen> COI 3ό20 <select_grade:-- C01 365E .credvαuchs - COI 3c-όD car vouchs COI 367C .carwashs '

COI 378A '.cashs.- COI 37 E-1 credits. 1 coi 37CC .thankyou.

CO1 CO|

-no-

COI 3S7D <credtrails>

COI 3BSC < ashtrails

COI 3S9B <card_formats

COI 396C <types_string>

COI 39B3 <First_πon_blan

C 1 39EF <Last_non_b1ank>

COI 3A2A <Trim>

COl 3A75 <Type_of_card_choice>

COI 3BOC <Type_of_petro_card>

-COI 3B97 <video_receipt>

COl 3ED3 <video_dollars>

COI 3F20 <video_card>

COI 3F55 <car_ ash_choices>

CO1 3F5F <i_need_attention>

COI 3F7D <price_change_compl ted:

CO1 3F9C <give_me_pump_map>

COI 3FBB <give_me_t,imestamp>

COl 3FDA <kiosk_payment>

COI 3FF7 <kiosk_authorise>

COl 4016 <here_is_a_traπsaction>

COI 4033 <i_have_a_hot_card>

COI 4052 open_bulloch>

COI 4078 bullochs_id>

C 1 408E <bul1_cmd>

COI 40EB <pumρ_money_audiα>

CO1 4115 <announce audio>

-III "

COI 413D <pump_number_audio

COI 4165 card_choice_audio>

COI 41BE all_cash_in_audio>

COI 41B7 <receipt_no_credit_audio>

COI 41E0 <receipt_credit„audio>

CO I 420 9 <-.pay .choice_audio: f jj_ 4232 ■■'■■petr _card_a di

CO1 425B ■ out_of_service.au d io.-

COI 4 234 <bad_note_audio

COI 42AD <kiαsk_alerted_audio.

COI 42D6 <bad_card_audio>

COI 42FF <printer_dead_audio

CO 4328 <pump_or_else_audio>

CO1 4351 rep1ace_your_card_au d ιo:

COI 4-37A ■■.other_card_audio. -

COI 43A3 .-..cancel

CO1 4 3F5 -.:card_auth_audio" :

C O i 441E - , ot_card_audio ;

_ Q 1 4447 <declιned card_aud_ o

_ 0 i 4470 < . . card_abend_a dιo.

•r i

COI 4499 :.caεh_abend_audιo.-

COI 44C2 <replace_πorzle_audio

COI 44EB <kiosk_halt_audio. ' .-

COJ 4514 <system_do n_=.udιo

COL 45 . Mi nn -_r_*.i-- - | .--.ι. d i l L . j v:. ιl -* card \ -. -._■- a' .. -wi. --.< .

- IIX -

COI 45BF <both_readers_down_audio>

COI 45B8 <remove_card_a_dio>

COl 45E1. <card_auth_video>

C I 460A <longer_card_auth_video>

COI 4633 <goodbye_thaπks_video>

COI 465C <lift_πozΞ ' ie_video>

COI 4685 <remove_card_video>

COI 46AE <iπsert_card_vtdeo>

COI 46D7 vinsert_bill_video>

COI 4700 fill_video>

.COI 4727 lift_and_pa_y_at_kiσsk_video>

CO I 4750 get_event >

CO 1 .4799 < 1 og_d ave >

COI 47B0 <pos_active>

COi 47DA <pos_whats_header_l>

COI 47FE <pαs_whats_cards_date

CO! 4827 <pos_decode_card>

COI 4850 <pos_authorize_card>

C01 4S7F <pc>5_caρture_transaction>

COI 4SB4 <pos_server_alive>

COi 4SCA <open_pos_server>

COI 48EB <pos_cmd>

C01 4963 card_light_on>

COI 497A <card_light_off>

CO! 4991 <cash_light_.oπ>

CO1 49 MO 1 iqht of-

-111-

- I I -4—

COl 4D63 <display_frame

COI 4DSB <o eπ_screen>

COI 4DA2 <open_screen_warm>

COI 4DB9 <graphics_server_alive>

COI 4DE7 <display_prices>

COI 4E10 <display_cl ar_oreρay>

COl 4E27 <di play_traπsaction_type

CO1 4E4A <dis 1ay_cash_in>

COI 4E67 <display_pumρ_number>

COI 4E84 display_preset_label>

COI 4EA7 <display_grade

COl 4ECA <display_preset>

CO! 4EED <display_card_type>

COl 4F0A <display_caεh_iπ_low>

COI 4F27 <display_user_cancel_credit>

COl 4F4A <display_system_cancel_credit:

COI 4F6D <display_credit>

COI 4F90 <displ y_string>

COi 4FC4 <disρlay_string_centred>

CO1 5050 <Irequeεt>

CO1 50 S <open_pump>

COI 50CE <pump_halt_now

COI 50E2 . pump_restart_now

COI 50F6 pump_ready_for_fill>

COI 510A <pumρ__hαse_selected>

CO1 511E <quie _ρum >

COI 5132 <pump_is_hook_down_now> COI 5146 pump_is_hαok_dαwn> COI 515A repαrt_pump_out_of_service> COI 516E <pump_ ill ing_data_request>

*• * COI 51S2 <pump_hαse_totals request

CO1 5196 . <pump_hose_ filled ' "

COI 51AA -.puιiιp_preset_reC|Uest .•

COI 51C4 <pump_id_request:

COI 5IDS ■■. ' authori e__pump>

COI 51F2 <set_pump_sale_corr.plete>

COI 5206 <pump_statuε_request >

COI 521A <pump_prices_request

COI 522E <pump_go,_tσuchcom:-

COI 5242 puιTιp_go_rιati VG>

C0.1 5256 .pump_chaπge_pπ ceε.-

COI 52A7 -.srequest.

COI 530D =:.open_touchscreen: ;

COI 5344 de ine_tαuch_;one

Col 536B ':clear_toucn_.;.Dnes '•

Col 5397 -'.deactivate _touchscreen.

Col 53C3 :,ύ tΪ ate__tDucnscreen :

COI 53ED <t_-uc _statuB request ' :-

COI 546E (start_event_queue>

CO! 54A5 ■:.cal err.-

COI 54B4 -scajj n " '

Cυi '_jώL I 5i.F " ;.

- l i b-

COI 57 2 <calnwork>

COI 5899 <calsplit>

COI 5B9D <calwkday>

COI 5C08 <caltimezone>

COI 5C23 <_calcsecs>

CO1 5C 7 <d ves_πame>

C 1 5C85 <f tou>

COI 5C9D <fatol

COI 5CCC <shell>

. O1 5D90 <chain >

COI 5DDB <create>

COI 5E43 <rem_create>

COI 5F8C <vc_release>

COI 5FA3 <tsscaπf>

COI 65E3 <sleep:

COI 6629 <abs_sleep>

COI 664E <set_timer>

COI 66B5 <strncpy>

COi 66EF <strncat>

COl 6723 <strncmp>

CO1 675B <register_πame>

COI 6821 <fseek>

COI 6901 <ftell>

COI 6966 <dregister_name>

CO1 6B0C <find_admin>

COI 6B7 <caHoc>

-\π-

-U -

col 6CDF nargs>

COI 6CF5 <memcm >

COI 6D20 <memchr>

COI 6D4D <memccpy

COI 6D8Q <atαl>

COI 6E24 1epilogue

COI 6E2D lmul

COI 6E7C Imodr

COI 6E85 lmod

. COI 6E8B ldivr

COI 6E94 ldiv

COI 6F4D <vc_send_reply

COI 6F53 <vc_create>

COI 6F59 <vc_create2>

COI 6F5F <vc_create3>

COl 6F65 <ker_vc_destroy>

COl 6F6B <def_server>

COI 6F71 <set_acc_flags

C 1 6F77 se _eκception>

COI 6F7D <escape_tty>

COl 6F83 <hαld>

COl 6FB9 <unhold>

COI 6F8F time_slice

COI 6F95 <task_info>

CO1 6F9E-1 <force_ready>

COI 6F 1 =.set Drioritv >

-i -

-llo-

DOO 0021 'My_tty- S

DOO 0022 stac _base

DOO 0024 <.C d_f1ags>

DOO 0025 <My_priority

DOO 0026 stdin-

DOO 0023 εtdout

DOυ _<02M stderr

DOO 002C Free_lιst.

DOO 002E End_of_free

DOO 0030 Fi1e_l lst -

DOO 0032 '_Argc"-

DOO 0034 stk_lιmιt

DOO 0034 _Argv

DOO 0036 SAVE

DOO 0038 TEMP

DOO 0060 'Code_flags

DOO 0061 User_πum -

DOO 0062 Group_num

D00 00 Tea _nu

DOυ 00o7 Dads_nιd

DOO 0069 My_tty_nιd

DOO 006B My_cd_nιd -

DOO 006D Release_num -

DOO 006E Ndp_save_area

DO' 5 t ) 0 ' l : __-!.<_>.-1

DOι) DOT \ c. t l I <>ι ' I

D00 0074 <Segment_table_ptr>

DOO 0076 Check_point_sp

DOO 0078 <Use _s re>

DOO 007E <Qdb_tid>

D03 0EB7 <devices>

D03 OFDB <debug_event>

D03 OFDD <dave>

D03 OFDF <_current>

D03 1076 <_previσus>

D03 HOD <T>

D03 11OF <P>

D03 1111 <now>

D03 11IB <Daves_error_statLis>

D03 HID <transaction_traρ>

D03 11IF <post_pay_trap>

D03 157F <egueLte_id>

D03 15A3 <dr>

D03 1865 <Create_status>

D03 1867 <Create_taskid>

-ii/i-

appl /decode_pump. c

#include "vars.h 1 #defιne NHOSES

#define REGULAR

* ttde-fine UNLEADED 2

t / pedef struct . unsigned cash_ρπce; unsigned credit_ρrice; unsigned grade; 1 hose;

static hose hoses C 3 3 = C υ, 0, REGULAR, 0, 0, UNLEADED., 0, 0, PREMIUM

static unsigned _maρ_ mi tial ired;

decode_pπces . b ) char *b;

•_•

* tsscanf ( b, " /.4d-/.4d7.4d7.4d7.4d'/.4d" , ϊ'hoseεπ . cash_pπce, ..hoses CO 3 , c edi t_prιce, tho≤es L " I II .. cc<<=.h \ ~ <f ~ CP, ?/hoses_.r 11.. creel, t pr _.-.•,

- \1 i+ -

T->regul r_price = Cash_price_of ( REGULAR ) 5 T->unleaded_p ice = Cash_pri e_o ( UNLEADED > 5 T->premium_price = Cash_price_of ( PREMIUM );

decode_grade< ahose ) .unsigned ahose? r

ahose—; return ahose < NHDSES ? hoses C ahose 1 . grade : 0;

static char _filling_data L 50 3;

decode_fill_dat ( c ) char *-c; r. zero. _filling_data, sizeof ( _fi lling_data ) ); COPY_SAFELY( _fi11ing_data, c ) 5 tsscanf (c, " VΛύV. ld"_6d" „ _-:T—>ρrice_ρumped, ξ.T->vαlume_ρumped, ι:T->cents_ρ imped > ;

char *typed_filling_data( cash, auth, response ) unsigned cash; char *auth , *resρoπse;

char -*p = _ i11ing_data + 17, c = _filling_dataf_ 16 3;

_fillιπg_dataC 16 3 = tαupper < c ) ; switch ( T-.--type ) r

ca._ _ CAF.D_TF.ANoACTi(l s iLr ny i p, "OOOOOOO" . , _.rf-_ai ;

case CASH_TRANΞACTION: tsprintf < p, ""_07u" , cash ; ; bre

case P03T_PAY_TRANSACTI0!\|_ tsprintf

( p, "%5.5s7.2.2s" , auth, response > ; brea

return _ l 11 ιπg_data;

ιose_αf . agrade . unsigned agrade;

for . l = 0; l 3; I t )

L ' hosesC L J. grade = : - agrade ) return l + 1;

» »

Cash_prιce_of ( agrade ) un s i q n ed c- q r ad ε ;

int i ;

for ( i = 0; i < NHOSES; i++ ) if ( hosesC i 3.grade == agrade ) return hosesC i 3.cash_price;

return 0;

Ini ti al iΞe_pump_map C apump )

Linsigned apump; C char -*e; unsigned the_grade, i J

if ( _maρ_initialised ) return; give_me_pump_map ( apump ) ;

do new_event ( Se, BULL0CH_EVE T) ; while . i Equal Jrruffers. e, "MAP", 3 ) ) ;

e += 3; for < i = 0; i < 3; i++ )

C the_grade = UMCHAR ( *e+t ) + 1; if ( 1 <= the_grade S.5-. the_graoe <= 3 > f'loses L i J_ G ade? = the cir dei

_map_initialized = I5

-ii β -

app l /del ay. c ■11- j. n c 1 u d s •* .11 ιTι fi . h .-'"

del ay (ticks) unsigned ticks; <. set_timer (TIMER_WAKEUP, RELATIVE, ticks);

appl/device.h

#defiπe NDAVES

typedef struct - unsigned video_port_; unsigned touch_port.; unsigned pump_ρort; unsigned bLil1och_por ; J- dave_device;

dave_device devices C NDAVES 3 = -C

<. 25, 2ώ, 27, 29

-VL°i- - appl/devi e_error. c

#include "vars.h"

#include "exceptions.h" ttinclude stdio.h ' -

#ιnclude "screens,hi"

Device_errα . cods, er or_message ) int code; char *errαr_message; -C char *e,

.:ιosk_message C 30 3;

if . debug_event )

tfprint-. ' stderr, "device e ro "»d "',=\n"_ code,

Daves_error__statu-_ ) ;

1 og_me ( Daves_errσr_status ) ;

_t ( c ό& ------ PRINT„FAILURE )

_ pr i nter _deacl_audι o ( T-- J nqLiarje ' r new_event < .-e, SHDW_DVER ); if ( memcmp ( Daves_error_status, "RI", 2 ) == 0 ) error_message = "PAPER LOW";

* r_ show_screen( dave, SYSTEM_PROBLEM_SCREEN ); kiosk_alerted_audio( T- language );

tsprintf ( kiosk_message, " _d%14s d", dave, error_message, T—>pu.mp_id_ρLimped ) ;

i_need_attention ( T->pumρ_id_ρumped, kiosk_message ); do r w new_event (&e, BULLOCH_EVENT) ; 3- while ( memcmp ( e, "RESET", 5 ) != 0 );

appl/disp_prev.c #include "vars.h"

display_previous_transaction ( )

display_transaction_type( dave, T->1 nguage, P->type );

if < P->type == CARD_TRANSACTIDN )

display_card_type( dave, P- card_type );

else if < P->type == CASH_TRANSACTIOIM )

display_cash_in_low ( dave, P->cents_in ); display_preset_l bel ( dave, T->language, P- preset_amount )

*

app /dα_a_ i 1 1 . c Do_a_f i l l ( )

if ( Proceed_to_fill ( ) > C

Fill_er_u ( ) ; car_wash_chαiceε ();

calculate_totalε (); -Send cnt headers <); /* just in case cnt reset */

appl/equal_buf.c Equal_buffers( bl, b2, len ) char *bl, *b2; unsigned len; r

return memcm ( bl, b2, len ) == O;

\^Tb-

appl/exceptions.

#define JUST_RESET_ME

#define USER_TIMEOUT_WITH_MONEY

#define PRI T_FAILURE

#define CANT_READ_CARD

#define CAMT_.EJECT__CARD

#de ine STACKER_FAILURE

#define CANT_READ_NOTE 8 ttde-fiπe LDST_PUMP 9 ttdefiπe POWER FAILURE 10

/-* "cancel" exceptions -*/

ttde ine CANCEL_ME_PLEA5E 10 ttdef i ne CARD_REFU3ED_P0S 1 ttdefine OTHER_ACCEPTED_CARD 15 ttdef ine NON_MAG_CARD 16 Φ Jefine POS INACTIVE 17

app I / ill er up _ c #include "screens. h" #include "vars.h" #include "exceptions. h"

Fill_er_uρ< ) /* here because we believe fuel has flowed */ r. unsi ned et_, char *e,

*get_pump_even < . ;

Reset_ ios _halt ( ) ; fill_video( T—>1anguage, T->ρreset_amount ,

User_needs_help ( ) )j whil ( et = πew_event ( ?.e, PUMP_EVENT i CONTROL_EVE T ) )

if ( e == PUMP_EVENT ) goto fi11ings_over; else if ( et == CDNTROL_EVENT > ; r

it . -juai _ϋUtτ£ 5. e, ''HHL ' HUMP'" j '— ' } . i<i αsk_hal ted . _us C ) ; else if ( Equal . buffers < e, "RESTART PUMP", 11 )

Kiosk_restarted_Lis ( );

-V -

i 11 ings_over: if ( event_success_code< ) != 0 ) longjmpC transaction_tra , L0ST_PUMP );

if < Equal.buffers, e, "NORMAL", 6 ) )

T- fιll_term_ nation = N0RMAL_F1LL; else ir . Eq_ι- _buffer . e, "ABNORMAL", S . t T- -fιll_termιnatιon = SYSTEM_ABEND; else

T-:-fil = SYSTEM_ABEND; pump_filling_data_reques . ); e = get_pump_event < ) 5 decode fill data< e );

static unsigned _l ιos. halt;

Reset kiosk halt. )

. IDS! halt = O

Kios. _hai ted_us( ) r

if ( _kios _halt == 0 ) /* in case someone gets confused */ r

L show cree-n < cia ^ c , I lUϊT .HΛL1 Eϋ β RL LLIN ) *,

=_ in j "' * 1 ? o > 1" 1 ■. ) ϊi

- .-bb-

video_of f ( dave ) ; kiosk_halt_audio ( T->laπguage .5 _kiosk_halt — Is

iosk_restarted_us< ) r

if ( _kioεk_halt )

C stop_video_show( ); /* in case it's a short halt */ show.screen C dave, T- type == P0ST_PAY_TRA1MSACTI0N ?

* LIFT . FOR . KIOS .SCREEN : FR0CEED_T0_FILL_SCREEN > ; ρump_restart_now( );

_kiosk_halt = 0; fill_video( T->language, T->preset.amount, 0 );

.| " .| > 1 f K.\y I I ■ _ I f f i ( i I il .. ι_

4+ _ ! i ... J Lid t " " v <_.P S . ι"i "

#include "exceptions.h"

static char *e;

char *get_pump_event < ) £ new.event ( &e , PUMP.EVENT . ; if ( eveπt.sLiccess.code < ) ' = υ . longjmp< transaction.trap, LDST.PUMP > ; else return e;

appl/globals.c

#defιne GBLGEN

tiπciudc rs. h'

appl/headers.c #iπclude "vars.h"

static char .headerlC 40 3;

get.receipt . headers( ) \. char *ρos_whats_header_l ( ) ;

COPY.SAFELY. .headerl, pos.whats.header.l ( dave ) ); Trim. _headerl ) ; set.receipt.headerl ( .headerl ) ;

char *headerl ( )

re urn headerl;

appl /hot.card. c #include "vars.h" #include "exceptions. " ttinclude "screens. h"

hot.card < ) r

char *e;

stop_video_show ( ) ; show.screen. dave, HOT.CARD.ΞCREEN > video.off . dave ) ; πσt_card_audi o ( T— >1 anguage );

i_have.a_hot.card < T— pump_id.pumped ) : " log_me( "hot card" );

while ( new.event . §.a, BULL0CH..EVENT ) ) if ( memcmp ( e, "RELEASE CARD", 13 ) == 0 ) break5

log_me( "card released" .3 cnt.c d ( dave, "CO", 0 ); cnt_beep ( dave ) ; longjmp ( transaction.trap, JUST.RESET.ME ) 5.

-\L 0-

appl/makefi le

CFLASS = -S SOURCES = ©cfiles OBJECTS = ©objects

dave: *(OBJECTS) 11πkob_j c = dave K = objec ΞuuO m = _li ■_. » li.t_.L-. _. — . user sort dave.map f—1,2 +r copy dave /dave/dave

global s.α_ vars.h

- l l+ t-

appl /new.even .c #include "vars.h" ttinclude stdio.h> #include "exceptions.h"

static char event C sizeof (request) 1; st 11c unsigned 1ue.one5

new.event < e, event_mask ) char *-*e. unsi gned event_mask j! •C

Linsi gned et;

Daves error status — event;

do

et = get_event ( event, ..value.one );

if ( debug.event )

tfprintf (stderr, "er ".CJA.- "/.s\n", et , event); if < e == CARD.EVENT 5.S. event Z 0 1 == ' ' )

Disarm_card_reader ( ) ; if ( e t == NOTE.EVENT && event C 0 1 == 'N' )

Disar .note.reader ( ) ; if < et === CNT.EVENT 8.S. event C O _l =•= 'H' )

Cn ram rer>r-l c v ' .:

- _ •+ . -

Disarm_note_reader ( ) ; Disarm_card_reader ( ) ; > else if ( et == SCREEN_TOUCHED S.8. event C O .! !- 'T' ) cnt.bee ( dave ) ; else if ( et == CONTROL.EVENT ) process.control.event ( event ); else if ( et == PRICE_EVENT ) price_change( event ); else if ( (et S. eveπt_mask) * =~ 0 ) Unwanted_event ( et > ; 5 while ( (et S_ event. ask) == O ) ;

*e = event5 return (int)et;

proces≥ . coπtrαl.event ( e ) char -Jf-e; r

if ( * e == * T' )

Update.timestamp ( ) else

event_5uccess__code < > r

return value one;

*

Unw nted__event ( type ) ύ swi ch < type ) r \. case POWER.EVENT: Process_power_event ( ); break; case NOTE.EVENT: cnt_cmd ( dave, "AO", 0 ); break;

case CARD.EVENT. if ( event C 0 H == 'C'. return; cπt.cmcl ' dave, "CO", 0 ) ; orea. ;

Pr er,t ' ' -tif this is ;< nower t * _. L ,<≡hι " .down dΛvt

if ( Equal_buffers( event, "POWER.FAIL" , lo ) )

* longjmp ( transaction.trap, POWER.FAILURE );

/-* current format is YYMMDDHHMMSS */

Jpda s_timestamp

-\-+-¥~

tsscanf (event t- i, " /.2d'/.2d-/.2d7.2dX2d" , S.now.year, ..now. month, '.now. day, ?<no . hours, .-.now. minutes) ;

-I4-S-

appl/objects card_pay. o b 1 i n . o cash.pay. o

*- checkpoint . o ve _. a deco e.pu p . o device_error. o di sp.prev. o equal _buf . o f i 1 lerup. o delay. o hot_card . o logger . α do_a.fi 11. o post_pay. o pr i ce.change. o learning. o ge tμuiiiμt'Vtϊii t . recei t. forma . o gl obal s. o

* headers. o send.headers. o new.event . o pres _chαi ces. o p r i π t _ c a i- « o

_ l* -

print.refund.o print_docu.o print_recei t.o proceed.fi11. o process. o

:-ι_r t_"t.t I _r- . L_ select.grade. o strings.o tri . o type.of.card-o type.of_pet.o video.receipt.o wash choices. o

-14.-1-

appl/poεt_pay.c #include "vars.h" #include "screens.h" #iπclude "exceptions.h"

-p.

/* comes here because */ t * user ' = card αec.ined by 32-1 L */

/* guy has a card we don't ta.'e -*/

Post_pay.fi1l.intro( code ) unsigned code; r_ char -*e,

*get_pump.event ( ) ;

T- -type •= P0ST.P.-.Y.TRANSACTION; stop. ideo.show( > ; display.transaction.type( dave, T-.-language, T- -type ) ; deactivate . touchscreen ( . ,

Clear., los.- . author ization . ) .

1 los..authorize( T- pumρ__ d_puιnped • .

* swi tch ( code ) *

case POS. INACTIVE: a t. OTI IE ..ACC C-F' I ££.' .CARD: -i-i.-n sc. i -."--I i . -t.ι-, ( " ii!- 1 ! " '. " Cf-Ru -n. ΛΓΓM

-f \ - --

other.card.audio < T->language ) ; log.me( "other accepted card" ); Wait_show_over_and_auth ( ) ; break;

case CARD.REFUSΞD.POS:

Card.has.been.refused ( > ; break;

case NON.MAG.CARD: show.screen ( dave, NON.MAG.ΞCREEN ); replace.your.card.audio ( T— 1anguage } ; Iog_me( "non -mag card" ) ; wait.show.over.aπd.auth ( ) ; break;

_ as.authorised ( ) new event ( S.e, BUL DCH EVENT ) ;

pLimp.is.hook.down.now ( ) ; if ( Egual.buffers( get.pu p.event ( ) , "HOOKDOWN" , 8 ) )

lift_and_pay_at_kiosk_video ( T—>language ); new event ( __e , SHOW OVER > :

/* outcomes ares */

/* • 1) LTS cancelled the fill */

/* 2) User cancelled the fill */

/* 3) A Normal Fill */

Post_pay_end_of_fi11 () r

char *e;

switch ( T->f il l_termi nation ) r

case NORMAL.FILL. case USER.ABEND: case SYSTEM ABEND: break;

if ( T->cents.pumped != 0 ) /* user pays at kiosk */

\ r. show_screen( dave, THANK_YOU_KIOSK_SCREEN ) ; displ ay.pu p.nu ber ( dave, T->pump_i d.pu ped ) ; video.off ( dave ) ; kiosk.payment ( T->pump_id_pumped , hose_of ( T->grade_pumped ) typed.fi 1 ling_data ( 0, T->auth_number , T->respαnse_cαde ) ); pump_number_audio( T->1 anguage, T- pump_id_pumped ); new_event . S.e , BULLOCH.EVENT );

static int _ a;

Clear.kiosk.authorization < ) C ka = O Ϊ

kiosk authorization ( )

_ka = 1;

Kiosk has authorized ( )

return ka;

Wait show over and auth ( >

w i 1 C 1 ) ui π i nr.w F'JFW

case SH0W_0VER: return; break; case BULLOCH.EVENT; if ( memcm < e, "KIOSK AUTHORIZED",

16 ) == 0 ) Set iu k →. '• i ' -i fϊ . .--... Li C'l ' i J _

br eat

Card has been refLised( )

char *e; r i 1 r ' v t -" ' 1 *

shαw_screen( dave, ARD.RΞFUSED.SCREEM ); video. ff ( dave ) ; decl ined.card.audio ( T- language );

cnt.cmd ( dave, "CO", 0 ); cnt.beep ( dave ) ; log_me< "card declined" )~

wh11e ( i ; switch , new.event ( ξe,

CARD.EVΈNT : BULLDCH.EVENT : SHOW.OVER ) .

cast. SHl iμl_ OVER. tiudioε l a ed+t • if ( 1 tor. _has_authoπzed ( .. audi os.p] a e -•= 1 . v -•' f- ear i -, auth * show.screen < dave, REI OVE_CARD_ SCREEN ); remove_card_audι o ( T- ** language );

J b ea. ;

card_light_off ( dave ); else longjmp ( transaction.trap, CANT_EJECT_CARD ); return; break; case BULLOCH . EVENT. if ( Equal.buffers( e, "KIOSK AUTHORIZED", 16 ) ) set.kiosk.authorization ( ) 5 if ( aLid ios.pl ay ed == 1 > /* late aLith -*/

show_screen( dave, REMOVE.CARD.SCREEN ); remove card aL.diα( T— >lanquaqe ) Ϊ

break;

c.ppl/preset_choιces. c

#include "vars.h" #include "exceptions.h" #include "screens.h"

Preset.choices( )

T- preset.a oLint = 0; if (T-- l nguage == ENGLISH) displ y_clear_prepa ( dave ); show_screen ( dave, PRESET_CHOICES_ΞCREEN ) ;

Set. user. entry ( announce. udio . T- language, T- tti e.hour * - l ); new.event < .-e, SCREEN.TOUCHEO . ;

switch (*e) r. case 'P's return 0; case 'T'_ longjmp ( transactiαn.tr.ψ ., JU5T_RESET_ME > breal , case F' _ breal ; default : it <ιsd_g_ t( *e . )

T- preεet_amount = fatou( e, 2 ); brea. ;

l rWilL. lH I l- ( r

displ y_preset_label (• dave, T->language, T->preset_amount ); /-* Set.user.entry( preset_choice_audio( T->1anguage,

T->preset_amount > ) ; */ return 1 %

appl/price.change. ttiπclude "vars.h" . .include <stdio.h>

static char _pπce_data T 50 3; static unsigned price chanπ--'. rrq ested;

pπce_change ( e ) char -*e; r

_price_change_requeεted = 1;

__erα( _pπce_data, sizeof ( _pπce_data ) ); memcpy ( .price.data, e + 6, 24 > ;

return _pπce_data:

pπce_change_requested .

return _pπ ce_chang _requested;

pri ce_change_done ( pump ) unsigned pump;

ni'i cc .hangf-

— l-S ' b-

price_change_completed ( pump )

appl/print.car.c

#include "vars.h" #include <stdio.h> #include "receipts.h"

pri nt_car__ ash__voucher ( . r

char m C 130 1,

*p; /* p = m + 1; C 0 1 = ' ' ;

strcpy ( + 1, "\02001"); wheader ( + 4, 0, T->trans.seq_num) 5 tfprintf (stdout, "7.d\n", strlen (m) ) ; priπt . cnt ( ) ;

P = r . wash . i e izer (m t 1, T—>car_ ash_amount) ; p = wtrailer(p); tfp in f (stdout, "7.d\n" , εtr1er. (m> ) ; print.cnt <m) ; */

SUBSTITUTE SHEET

-l6 < 8-

appl/print.docu.c

#include "vars.h" #include "receipts. "

Print documents( )

char m C 15 3 ,

*print_cπt ( ) , *p = m;

both_speakers_off ( dave ) ; colurhn.speaker.oπ ( dave ) ; receipt.light.on ( dave ); set.document.l nguage( T— 1 nguage ) ;

zero( , sizeof ( m > ); *p++ = 'R'•

Print.receipt ( T->type == CARD_TRA SACTIO ? binauth( >

: T— traπs_ seq_nuιTι ) ; if ( T->c ange_dU5 ! = 0 ) r

eject_aπd_perf orate ( p ); p = pr.int.cnt ( m ); Print.credit.voucher ( );

eject . c il (P) ;

print_cnt ( m ) ; receipt_l ight_of f ( dave . 5 n_ *

appl/print.cn .c #include "vars.h" #include "exceptions,h" #include "screens.h"

char -s-print.cnt (m) char *ιϊ!5 r

char *e; int et;

cnt.cmd (dave, m, 20) ; while (et = new.event (S.e, PRINT_EVENT ! 3HOW_OVER) ) r * it (et == SHDW_OVER)

yideo_of (dave) ; continue?

shD _screen (d v , PRIMTER.BRQKEN.SCREEN) 5 longjrnp (transaction.trap, PRINT.FAILURE) ;

J el e return m + 1;

-lb!-

appl /print .receipt. c

#include "varξs.h" ttinclude "receipts. h"

#include <stdio.h>

print_receipt <)

char m I 130 3 ,

*P;

zero (m, sizeof (m) ) ;

P = ;

*ptt = 'R' »

p = f ormat_header (p, T->trans_seq_num, T->pLuτιp_i d.p Limped ,

T->ttime) ; p = f ormat.f i 1 l . data (p, T->volume.pumped , T- grade. pumped ,

T->price__ρumped) ; if ( T->type == CARD.TRANSACTIDN ) p = for mat .car . te der (p) 5

p = for at.fuel (p, T->cents_pumped) ; p = format.total (p, T->total_due) ; if ( T->type == CASH_TRANSACTION ) r

print. nt (m) 5 z e o ( . si ~~ eof ( . ) .'.

— IfeSL-

p = m;

*p++ = 'R'- p = format_cash_tender (p, T->cents_in 5 p = format_chaπge_due (p, T—>change_due) ;

priπt . cnt ( ) ;

appl /print .re und. c

#include "vars.h" ^include "receipts. h" .inclLide <stdio.h>

pr i nt.credi t.voLicher () r

print_.receipt ()

-.b"r~ appl /proceed.f ill . c

#include "vars.h" #include "screens. h" ttiπclu e "exceptions. "

F'roceed.to.f i 11 () r v. ar ~? ~ Q st___pu.fπ __Θvε?n"t ( ,

unsigned et;

card.light.of f " ( dave ) j cash.l ight.of f ( dave ) ; deactivate.toLichscreen ( ) ;

stop.video.sho ( );

if type — :.ASH TRANSACTION )

lift.noz le.video ( T—.--language ); πew_event. _. , IDEO.SEEK.EVENT ); show screen ( dave,, PROCEED TO FILL SCREEN )

εhow.screen ( dave,

T->type = *** - P0ST.PAY.TRAN3ACTI0N ? LIFT.FOR.KIOSK.SCREEN PROCEED TO FILL SCREEN ) ;

ff \ k$ - video off ( dave >

pump_hose_selecte ( > /* get an off hook */ while< et = new_eveπt < 8<e, PUMP.EVENT I SH0W_0VER ) )

it < et == SHOW.OVER )

video.off < dave ) ; continue;

if ( event.success_code( ) != 0 ) longjmp( transaction.trap, LOST.PUMP );

if ( Equal.buffers( e, "HOSE", 4 ) )

.r

sel ect_gra e ( e C 4 2 ) j; cαlumn ^ speaker ^ o-F-f dave ) ; bo h_speakers on ( dave ) 5 goto author!2e_itp

else if ( Equal.buffers( e, "TIMEOUT", 7 ) )

T->fill.termination = USER. BEND5 return 0;

else if ( Equal_buffers( e, "WARNINB" , 7 ) )

stop.video.show ( ) show_screen( dave, PUMP.OR.ELSE.SCREEN ) ; pump.or.else.audio ( T—>1anguage ) j cnt.beep ( dave ) ;

e se

T->fill _.t_.rιιιl Fici L.1 JI i SYSTEM ABEND; retLtrπ 0; /# buq in syste

authori;_:e_it: authorize.pum ( T—>preset_amount )~ if ( 1Equal_bu fer ( get.pu p.eveπt ( . "AUTHORIZED", lO ) )

T->filI termination = SYSTEM ABEND; return 0;

whi 1 e 1 )

e = get . pLimp.event ( ) ; if ( Equal .buff ers ( e, "WARNING", 7 ) )

stop.video.show C ) ;•

._n,._... s .__ f _ι _..._ p. i \ι,._r__. ι~.ι__~; r_-. ,—. :r- .— rf-C-jr CT i

:=.! ι_...-v __.\_ - c'l I '. ■_! c - ϊ:_ ., * l ..'ϊ • .. -. L. L ~ >* . __ ... P. __. _~ ;

_[lo-7- * pufTip_or_el ( 7- language ) ? cnt_beep ( dave ) ;

% else if ( Equal_buffers( e, "ABNORMAL", 8 ) ) r i

* T- -fill, termination = SYSTEM. ABEND 5

else if ( Equal _buf f ers ( e, "TIMEOUT" , 7 . ) \ r.

T- -fill_termιnatιon = USER. BEND; return 0;

-J.

else it ( Equal_buffers( e- . "HOSE', J . .

seLe .iii" ade ( eC A 3 > ; show.εcreen ( dave,

T-.type == POST.PAY.TRANSACTION - ~ LIFT.FGR.I- COS'r .SCREEN :

PROCEED.TO.FILL_SCREEN ; StOf;_v1 dO_i.ShC' ! ' J . ' ;

* else if . Equal_buffers ( ε_ „ "FUEL FLOW", <=> . )

» return 1 ;

* else r

L

T- fill L er ui l π a 11 or. = Y? I L11 ABEND ; i' ts urri ». ) ;

appl/ rocess, c

#include "screens,h" Mπclude "vars.h" #include "exceptions.h" #inclLide <stdio.h>

i L-ci 1 l_ j fIi|_f '--'Li

_ptrap;

Process transactions( )

unsigned t;

transaction.trap = ...ttrap; ost.pay . ap = ξ._ρtrap5

1/4 i iJ.1 fc_ . J. if ( t = set jmp ( transaction.trap ) )

Process.exception ( t ); el se

Pr uLd5_>_BK Bμtiori ( type ) unsigned type;

char *rr.sq:

ϊ l uec GT

l 0 !-

stop.video.show ( )

if ( type == JU3T.RESET.ME ) C card.light.off ( dave ); cash.ilgl'ih.otf ( dave . ; re eip t__ L J ght_ i -• '. >J- ~ , ■ c ι return;

if ( type == POWER.FAILURE > rτ.

Power.has.failed ( ); return;

switcli < type )

case LOST.PUMP: msg = "U/SlPUMP. "- break-, case CANT.F-.EAB.CARD * msg ~ "U/3(CARD READER. "; brea. ; case CAMT.EJECT.CARD. msg - "U S.CARD STUC. > "ϋ brea. ; case CA T.READ.MOl Es msg = "U S ( NOTE READER ) ";, tireal ; case PRI T.F ILURE. msg = "U/S (PRINTER) "5 breal case STACK.ER_FAIL.URE: msg = "U/S (STACKER) "; break; default: msg = "OUT OF SERVICE"; brea.:;

ias v l c ι_ . ■ - 1- or , μe m u

__. ΠO-

one sale( )

unsigned why;

Reset.al1 ( ) ; Language choice v ) 5 while( 'Preset choices ( > ) incεlIinq between sn

if (T->laπguage == ENGLISH)

T-> language = FRENCH j else if (T->laπgLiage == FRENCH) T->1 anguage = ENGLISH;

if ( why = set jmp ( poεt . pay.trap ) )

Post.pa.y.f ill _i nt r o ( why ) ; else

Payrrient.loop ( ) ;

1 i' ( debLt .event . tfprintf ( stderr, "USER SPEED .-_d\π", User. speed.f actor ( ) );

Do.a . ill ( ) ~ t ake.sure_the_hook_is.down ( ) ;

if ( T->type != POST_PAY_TRANSACTION )

p .J "r ' _ * tl L""' t : . I I " ir- τ l ~. •_ 1. ...!' • * <■

Pre.pay.transaction.outcomes ( ) ; than .you( ) ; save.previous.transaction ( ) ;

else

Post_pay.end_of.fiil ( ); 1og.transacLion ■> > ϊ

-.eset al1 < )

char *get_pump_event ( ) , *e;

stop.video.show ( • r, video.off ( dave ); both.speakers.of f ( dave ) 5 column.speaker.oπ ( dave ) 5 Reset.learning . cLirve ( );

er i ( I ., SΪ_:EΌ! \ -'■■- X • ) !-, . • clear curi- c-n . i rαnr -\c1._ on strep/ ( T-;-auth_numbe , "00000" );

T- -resμoπse.codeL 0 1 = "-.' ' ;

T->respαnse_codeC 1 1 = '9';

T->grade_pumped = P->grade_pumped;

T->1 anguage = ENGLISH?

T-- .-tranε_ seq_nurn - P- trans. _serι_rιu.ιn t . ;

— YΎ - pump.id . reques ( ); e = get_pump_eveπt ( ) ;

T->pu p_id_pumped = UNCHAR(etέ-3) ; /* "PUMPIDn" */

if ( price.change.requested ( ) ) /* now is a good time */ r u pLimp . change . pri ces( ρrice_data( ) , bu] e — e . tiϊip . everc * . s price.change.done (

Initiali-r.e.ρump_map ( T->puι-np_id_pumped ?

/* get plumbing straight */ pump.prices.request ( ); /* get the latest prices */ e = get . pLtfTip.event ( ) ; decode.pr i ces ( e ) ;

gi ve_rne_ti iTiestamp ( T— pLimρ_i d . pumped ) 5

/* αet the cu.rrent time */

__.<_.rιι_|i-.a_jfc_: _iiDli

unsigned idling = 1; int et?

show screen ( dave, LANGUAGE SCREEN ) -,

-rri- report.pump . out.of.servic ( T- pump.id . pumped );

blink.on ( ) ;

whιle( idling ) r et = new.everit ( Ze ,

SCREEN , TOUπ-IEϋ ', pRirC . E'^EMI ! P 1 INF . EVENT ) , l f ( et == SCREEN_TϋUCHED idling = 1anguage_screen_touch ( e ); else if ( et == PRICE.EVENT )

C quιet_pump( T- -pump_ιd_pumped ); blιnk_off( ); longjmp ( transaction_trap , UST_F.ESET_.IE ); brea. ; ->

else if ( et == PUMP.EVENT ) r. bl in..off ( ) $ i or i g j fn . i &n_>_cfci or i x. _.ιρ ■ brea. *

quιet_pump( T-. pu p.i d . pumped ) blιnk.off ( );

-T7^

1 aπguage.screen.touch ( e ) char *e;

switch (*e>

IciSE T- 1 anguage = *e == 'F' ~ ' FRENCH Ϊ. ENGLISH? T— >ttifiie = now; return 0; break; case 'T': if ( pri ce.change.requested ( ) )

quiet . pump ( T— >pump_i d.pumped ); blink_off ( > ; longjm ( transaction.trap, JUST.RESET.NE >

gi ve.iTte.timestamp ( T— >pLimp_i d.pumped ) ; reactivate.l nguage.touchsones ( ) ; break?

e urn 1?

Payment.loop ( )

whi le ( 1 )

- US ' - switch (T->type) Z case CARD.TRANSACTION: if ( Card_payment ( ) ) return; break;

breaks

Pay_choices( )

show.screen ( dave, PAY.CHOICE.SCREEN ) ? video.off ( dave ) ;

Set_user_entry . pay_choιce_audiσ ( T—Manguage > .> ~ n w.event '. ≤.e , SCREE . " ! GU HEO ) ;

swi ch ( fee > /

case 'T': longjmp ( transaction.trap, JUST.REΞET.fE ) ; break; case 'C' :

CASH.TRANSACTION; display.transaction.type( dave, T— 1anguage, T—>type ) ; break; default; break;

*

calculate.totals ( ) r

if ( T->type == CARD.TRANS CTIDN)

T— >cents.iπ = T— >cents.pumped + T— >car_wash_amount;

if ( T— >preset_aιτ>θLint ! = O S.S. T— >cents_pLimped > T—ϊ-preset . amoLint )

T— >cents_puιτιped = T— >ρreset_amount; -* my ump unne h over * T— >total_due = T— >cents.pLimρed t T->car.wash_amount; T->chaπge_dLie = T— >cents_in — T->total .due;

Nake_sure__the.hook_is.down ( ) -\. char *get_ρumρ_event ( ) , *e;

stop_video_show ( );

pu p_is_.ho k __dov- * n no.-.

— \ιn —

if ( !Equal_buffers< get.pump.event ( ) , "HDO DOWN" , S ) )

show_screen( dave, REPLACE.NOZZLE.SCREEN ); ir

# video.off ( dave ); replace.nozzle.audio( T->1anguage ); new.event ( 8.e, SHOW.OVER );

pump.is.hook.down ( ); get.pump.event ( ) ;

/* outcomes are: */

/* 1) LTS cancelled the fill */ /* v 2) User cancelled the fill */ /* 3) A Normal Fill -*/

Pre.pay.transaction.outcomes ( )

switch ( 11 .rmination )

case NORM L.FILL; Receipt (' ); break;

* case USER.ABEND: User.cancel.recei t < ); break; case SYSTEM ABEND: System.cancel.receipt ( ); break;

Recei t.

— f-7 S -

char *e; int display.credit ( );

Receipt.graphics ( display.credit );

if ( T—>change_due == 0 ) receipt.no.credi L_5UOI D - ■ —. ; -i.anguage ) ; else receipt.credit.audio( T—>1anguage );

new_event( 2.e, SCREEN_TOUCHED ); stop_video_show( ); switch ( *e )

case "' p ' „ goodbye.thaπks.video ( T—>1anguage ); show.screen ( d^ve, RΞCEIPT.STANDBY.SCREEM ) print.docLimeπts( ); break ;

Liser.cancel .recei pt ( )

ι_ n a i-

Receipt.graphics( display.user.cancel.credit );

if (T- type == CASH.TRANSACTION) cancelled.cash.audio (T-Manguage) ;

•* else if <T--type == CARD.TRANSACTION) cancelled.card_auα_ o (T— language; i e sε

new.event (_/e, SCREEN.TOUCHED) ; switch ( **e )

-C case 'P's print.documents (); breal ; case 'T ' 5 default. break;

ssstem.cancel .recei t < ) .

int di spl __•. _svstenι_ i-sin f i _ cr edi L . ;

Receipt.graphics ( di spl ay.system.carice] .credit )

if ( T--type ***■ = CASH.TRANSACTION ) cash abend audio ( 7- language ) ;

card.abend.audio ( T— 1anguage ); else 5 new.event( S.e, SHOW.OVER );

new.eveπtC &e, SCREEN_TOUCHED ); switch ( *e )

case 'P's print.documents ( ); break; case 'T ' : defaLilt: break;

F:ecei pt.graphics ( credi t.f uncti on )

PFI credit.function;

set_screen_timeout ( RECEIPT.BACKGROUND.SCREE ,

T->ch nge_due ? 30 : IS ) ; show_screen( dave, RECEIPT.BACKGROUND.SCREEN ); .* rs it.fLinetion. .α ve., ϊ—.J-c aπge. ϊe., T— 1an uage video.receipt ( ) ; video off < dave >s

thank_you( )

Slli

video.off ( dave ) ; pum .money.audio( ); delay( FIVE.SECONDS >

save.previous.tr nsaction ( )

*P = *T;

Push.chec. point ( ) ;

post.transaction () C char *tvped_fi11 ιng_data () ; char *pac. ed.auth.language( ) , *al ; unsigned cash;

if < T- type == CARD.TRANSACTION ./.< T- .cents.pumped '= 0 ) r

al -- pάc. fc_u_ c.Lith_i a uacie \ " 1 ~ auth .number ,

T— 1 arιguage_ codr 5 ) i pαs.capture.transact. on ( dave, T- card.number, al ,

T- -Cents.pLimped , T- grade.pumped , (unsigned) T- ' Volume.pLimped / 10, T- 'pπce.pumped );

i - C- i ' - L'UII 'tΞ f ! -- ' ) *

-IS3--

cash = T->type == CASH.TRANSACTION ? T->cents_in : O; ' here.i s_a.tr ansacti on ( T— >pump_i d.pumped , hose.of ( T— >grade_pumped ) , typed . fi 1 ling_data( cash, T->auth.number ,

T— >resρonse_code ) ) ;

εet.puiTip.sal . co pl ete ( ) ; get.pump.event ( );

static char _buf C 10 3;

char *packed_auth_language ( a, 1 ) ch ar -κ-a , 1 ;

zero( _buf , sizeof ( _buf ) ) memcpy ( _buf , a, 5 ) ; bufC 5 3 = 1;

log.transaction ()

char loom L 40 _

tsprintf ( logm, " '/.__ sale completed", types.string ( T->type ) > log.me ( logm ) ;

Power has faiie C )

:har *e:

log_rne'( "power.shLitdown" ); show.screenC dave, POWER.OFF.RECEIPT.SCREEN ); while( new.event ( ?.e, POWER.EVENT ) ) if ( Egual.buffers ( e, "POWER.BOOD" , 10 ) ) return; 'log.me( "power.reset" );

*

appl /receipt.f ormat . c

#i ncl ude "trans. h"

stati c char *hdr C D = r X

' ■■ TO1 PETRO~CANADA\015",

"T02 " ,

"T03 PUMP NO. " ,

"T04\015 REGULAR ",

"T05X015 UNLEADED ",

"T06\015 SUPER UNLEADED ", "TOT C/LN015 LITRES PUMPED " ,

"T0BX015 FUEL $ " ,

"T09\015 TOTAL $ ",

"T10\015 CASH TENDERED * " ,

"Tll\015 CREDIT DUE * ",

"T12\015 THAN -Y0U\015" ,

"T21 PETRD-CANADA\015" , /*- not used, here for symmetry -*/ '

1 __.-_. ,

"T23 POMPE NO. " ,

"T24\015 ORDINAIRE " ,

"T25\ 15 SANS PLOMB ",

"T2ώ\015 SUPER SANS PLOMB " τ "T27 C/L\015 QUANTITE ACHETEE " ,

"T28\015 CARBURANT φ ",

"T29\015 MONTANT DU * ",

"T30X 15 MONTANT RE IS * ", "T31\015 CREDIT * ",

* * "T32\015 MERCI\015",

'^50X015X015X012X012X012X012X012X012",

* "T51X015 PETRO#" ,

" " I 52X015 M.CARDtt" ,

"T53X 15 1SA#" ,

"T54X 15 UNr-NWN#", υ

static char lbuf C 40 3;

set.receipt.header1 ( s > char * •___ .

int length; char *c;

i u-i , ' , ≡ ιeo-1 lbuf ' i ) strcpy. ibuf + (14 - (strlen . s ) / 2 ) ) , s ) s length = strlen . hdrL 0 3 ) + strlen ( lbuf . -ι 10:

/* X015 #\0 t slop */

c = callocl 1, length ); tsprintf ( c, '"/.sy.sXOlS * »" , hdrC 0 3, lbuf > ; dr f 0 .1 •= ,-..

char *cnt_εtring< n > unsigned n; <. return hdrC n 3;

static unsigned 1; static char dbuf C 15 3;

char *dollars( amount > unsigned amount;

. tsprintf C dbuf σ ""'_3u.7.02d" , amount / 100, amount V. 100 ); return dbuf;

static char _abuf C 15 3;

char *cnt.text( field ) unsigned ield; r \. tsprintf ( .abLif , "X0207.02u", field ) ; return abuf;

set.document.language< .language ) uπsiqnεd 1anαuaqes

1 = .l anguage;

char *for at.header ( p, sequence, pump, t ) char *p'4 unsig ed sequence, pumps

unsigned hh = t. hours;

p t= tsprintf < p, ""is", cnt.text. 1 ) 3;

if ( hh • = 13 ) hh -= 12; p t= tsprintf ( p, ""/.05uV-s"/.02 : 7.02d"-'.s\015" , sequence., cπt_ t ..t( 1 ^ 22 _ 2 1 „ hh, t« mi utes, ampins c t.hnurs ) "> ;

p t= tsprintf ( p, " * /.02d-"/.02d-"/.02d7.s7.2d" , t. mont , t.day, t.-zear, cπt_te„ t ( 1 " " " 23 : 3 ) , pump . ;

return p

*

char * ormat. l 11.data( p, volume, grade, price > char *p;

'.in.-.] 14ri. ■ i fu.ii- r i i ι.

p += tsprintf . p , "7.s7.02d.7.d " cnt_teκt< cnts_grade( grade ) ) , price /10, price 7. 10 ) ;

return p + tsprintf ( p, "7_s%31d.7.021dL u , cπt_te>.t ( 1 ? 27 . . , volume / lOOL, volume 7. 100L ) ;

cnts.grade( g ) int g;

if ( g — 1 ) return 1 ? 24 s4; else if (g = * = 2) return 1 else return 1 6;

char *for at . card.tender < p ) r

return p + tsprintf ( p, "7.ε7.ε" , cnt.tex ( recei t_card.field ( ) ) , card.formats( ) );

- iff?- char *p; unsigned fuel ; C return p + tsprintf < p, "7.s7_ε" , cnt.text ( 1 ? 28:8 ) , dol 1ars < fuel ) ) ;

char -*format.total ( p, total > char *p; unsigned total;

return p + tsprintf ( p, "7.s7.s" , cnt.text < 1 ?29:9 ) , dollars, total ) );

char -format.ca≡h.tender ( p, cents.in > char *p; unsigned cents.in;

urn p t tsprintf < P <t te-::- ( 1730„ 1 ) doll rs< cents in ) );

char *format.change.due( p, change ) char *p; unsigned change;

: (' " hai ιq_-_ ' ~ < ■ )

p += tsprintf ( p, "7.s7.s" , cnt_text ( 1 ?31:11 ), dollars< change 3 ); return p;

char *eject () ,

*ρerforat O , *cut <) ;

char *eject_and_perforate( m ) char *m; . m = eject ( m ) ; return perforate( m );

char -*eject.and.cut ( m ) char *m; r

m = eject < m ) ; return cu ( ) ;

static char *eject ( m ) char *m;

+= tsprintf ( m, nv.— ιι cnt text < 1732: 12 ) ) j return + tsprintf C m, , cnt . text C 50 ) ) ;

-PH -

static char *perforate( m > char -*m;

*ω = ' \ ' 5 return m;

static char -*cut < m ) char -*m;

return m + tsprintf < \ 15\012\012X014" >

appl/receipts,h

extern char *format.header () ,

* o mat. ill.da a C) , #fαrmat.cash.tender (), *for at.card.tender <), --f r at.fLtel () , *format.total <), -*fαrrπat.change.due () , *eject_and_perforate () , *eject.and.cut <) ;

-tf'b- appl/screens.c

ttinclude "screens.h" #include "vars.h" #include <stdio.h>

/* standard touch areas as of Ju 27t

/* coordinates are touchscreen coordinates. * /

stati TOUCH.AREA _A1 C 3 J = -C

49, 456, 465, 758, ΕO", / * English •*/ 614, 456, 988, 758, FO" , /* French */

-1 -1

static TOUCH. ARE _A2 L 7 1 - i

816, 946, 96S, 994, "RO" /* r

50, 690, 263, 881, "05" /* 5 bucks */

384, 690, 516, 881, "10"

553, 69U, 751, 881, "15"

789, 690, 978, 881, "20"

214, 431, 328, 640, "FI"

•-. -1 -1

static TOUCH.AREA _A4 C 4 3 = .

54, 444, 321, 64<? , "CO", /* Cash */

73'?, 444,, 9S7, ' Card * /

- 1 , - J ., * L ,

-n* -

static TOUCH.AREA _A6 C 2 3 = C

155, 966, 881, 1023, "RO",/* Press strip to start again */ -1, -1, -1 " , -1, ""

static TOUCH. REA _A8 L 2 3 = -C

702, 577, 954, 759, "10", /* All cash in ? */ -1, -1, -1, -1,

static TOUCH_AREA _ftlO [ _ 1 = {

811, 943, 961, 1002, "RO", /* reset *-/

77, 587, 277, 765, "VO", /* visa •*/

435, 587, 634-, 765, "PO" , / * petrα Canada */

770, 587, 964, 765, "MO", /* master card */

87, 422, 958, 540, "GO", /-* all else */

—1 1 , —1A , —1X, —11 , ""

static TOUCH.AREA _A12 t 4 3 = C

456, 440, 614, 495, "RO" , / * reset */

58, 563, 480, 997, "BO", /* we can handle */ 587, 563, 962, 997, "BO", /* no mag stripe */

-1, -1, -1, -1, "

static TOUCH AREA A14 C 2 3

153, 968, 876, 1016, "RO" , /* reset */

_ x i ι _ A 1 ι _ι * i _ι > » no

static TOUCH. AREA _A20 C 2 3 = C 158, 543, 423, 742, "PR", '* Print Receipt */

~~* X f ~~~~ - "" X - "" * " * X n

static PICTURE l l al _A1, 30 3-; static PICTURE A2 _A2, 60 : ; static PICTURE A4 "a4" _A4, 30 ; s atlc PICTURE A6 _A6, 60 s static PICTURE A3 _AB, 0 3-; sta c PICTURE 10 .A10, 60 3 ; st tic PICTURE 12 "al2" _A12, 60 >j static PICTURE A14 * C "al4", _A14, 60 3 ; static PICTURE A16 - C "al6", NULL, 0 3; statJ c PICTURE 18 = "alS" , NULL, 0 . static PICTURE A20 = C "a20", A20, lυ 3-; st tic PICTURE A20C C "a20c" , NULL, 0 3; static PICTURE A 1 NULL, 0 static PICTURE A22A C "a22a", NULL, 0 > static PICTURE A24 C "a24", NULL, 0 ϊj static PICTURE SP2 C "sp_2", NULL, 1 ; p * caI i c I'LCIURE c.l-'S ; "<_μ . 5" , NULL, I : : r-'lCI LIRC -'& __μ NULL

n t>-

static PICTURE SP7 = -C "sp_7" , NULL, 0 > static PICTURE SP8 » -C "sp_8" , NULL, 0 3-; static PICTURE SP11 = -C "sp_ll" , NULL, 0 > static PICTURE SP13 = -C "sp_13", NULL, 0 3-; static PICTURE SP15 = C "sp_15" , NULL, 0 > static PICTURE 3P16 = -C "sp_16", NULL, 0 3-; static PICTURE SP17 = -C "εp_17" , NULL, 1 3-; static PICTURE SP21 - C "sp_21", NULL, 0 3-; static PICTURE SP22 = C "sp_22" , NULL, 1 ;

static PICTURE A3 'a3", _A2, 60 static PICTURE A5 'a5", _A4, 30 5 static PICTURE A7 "a7" , _A6 60 static PICTURE A9 "a9" _A8, 6 static PICTURE All ill", _A10 60 static PICTURE A13 al3", _A12, 60 static PICTURE A15 'al5", _A14, 60 static PICTURE A17 ai7", NULL, 0 static PICTURE A19 al9" , NULL, υ static PICTURE A21 static PICTURE A23 stati PICTURE A23A static PICTURE A: — r stati PICTURE A21C

static PICTURE El = el " , NULL , 0 3- ? stati c PICTURE __..__ — 2 " , NULL , 0 J

static PICTURE E3 = -C "e3" , NULL, 0 3-;

static PICTURE SP2F = C "sp_2f", NULL, 1 3-; static PICTURE SP5F = ' "sp.Sf", NULL, 1 3-; static PICTURE SP6F = -C "sp_6f" , NULL, 0 3-; static PICTURE SP7F = C "sp_7f", NULL, 0 3- 5 static PICTURE SP8F =-■ -C "sp.Sf", MULL, 0 3-; static PICTURE SP11F = C "sp.llf" , NULL, 0 3-; static PICTURE SP13F = -C "sp_13f", NULL, 0 3-; static PICTURE SP15F = C "sp_15f", NULL, O 3- ; static PICTURE SP16F = -C "sp_16f", NULL, 0 ; static PICTURE SP17F = -C "sp_17f", NULL, 1 3-; static PICTURE SP21F = -C "sp_21f", NULL, 0 3-; static PICTURE SP22F = -C "sp_22f", NULL, 1 3-;

static PICTURE /* language choice /* preset choices /* pay choices /* insert bill /# all cash in ? / * card type ? /* petro card type /* insert card /* standby autho i /* roceed i 11 * receipt '?

-m-

S.E2 , S.5P2 , S.SP5, 5.SP6 , &SP7 , &SPS , S.SP11, S.SP13, S.SP15, S.3P16, 8SP17, S.SP21 , S.SP22 , S.A20C

static PICTURE ♦French C MAXΞCREENS 3 /* language choice */ &A1 , /* preset choices */ ?<A3, /* pay choices */ S.A5 , /* insert bill -*/ • S.A7, /* all cash in ? */ /* card type ? */ &A11

/* petro card type -*/ 8.A13,

/* insert card */ _Α15,

/* standby authori */ ?..A17,

/* proceed fill */ _.A19,

/* receipt ? */ .A21,

/+• tnaril you *•' :ΆΓ -' . / * kiosk /* kiosk thanks /* out of order

?..SP13F, U-SP15F, :>3Pt F ,

f..3P 1F. ..SP22F , S.A21C

_eL " r t. er ι . J meoi i r ' - c. μ _ 11

LU is L αrie .cre -n _t I '

PICTURE *p = English C screen 3:

p —>touch_timeout = value;

reacti ate.language.touchzαnes () C deactivate.touchscreen (); clear.tαuch.zones (); set.touchscreen (O, EnglishC 0 3->touch_list,

EnglishC O 3—>touch.timeout );

show.screen.alone <dn, n) unsigned dn, n; C PICTURE *p = T->1anguage == FRENCH ? French C n 3 : English C n 3

display.frame (dn, p —>name. ;

show.screen (dn, n) unsigned dn, n; r _

PICTURE *p = T->1anguage == FRENCH ? French C n 3 : English C n 3

deactivate . touchscreen () ; clear touch zones ( i i-

-2.o\- -

if ( iiiemcmp ( p- name, "εp", 2 ) == 0 ) display.f ramet dn , p~ touch.ti eout ° "sp.full" : "sp.half"

displ y.f rame ( dn , p- ^ name ); set. touchscreen (n, p- touch.iist, p- touch.timeout );

swi tch , n '

case LANGUADL_8C EEN_ language_5cre_.il .dn) -, brea. case FRESET.CI-IQ] CES.SCREENS preset.screen (dn; ; brea.

static εet.toLichεcreen ( _ d , t, timeout ) unsigned id;

T i Γ uIL. IΓL_.Ir Il_ "*■ t. _ , int ti eout; r

r etiirn ;

for ' s i - left '--- - l; i t-i-i ciet inε . t uuch_ rorit * ' Jtrl , '■- bot om, t- right, L- L

acti vate.touchscreen ( id, timeout );

unsigned dn; C displ ay.priceε ( dn , T— >regul ar.price, T->unleaded_price,

T— >premium_price ) ; if (P— >grade_pumped != 0) display .grade (dn, P->grade_pumped , T— >1 anguage)

static preset.screeπ (dn) unsigned dn; r

display.prices (dn, T— >regul ar.price, T->Liπleaded.price ,

T— >premiuιτι_price. ; if (P— .'-grad .pL.fT.ped ! = * 0) displ ay .grade (dn, P— >grade_pumped , T— >1 anquaqe) ;

appl /screens. h

ttde ine MAXSCREENS 30

typedef struct C int left;

L T| _. L' L. L '-.ill ; int right; char -*t ame; 3 TDUCH.AREA;

typedef struct C char -*name;

T ' O DUI CH . HREA *tαuch_llst; int touch.ti eout .

3 PICTURE;

ttdefiπe LANGUAGE.SCREEN <-> * al */ ttdef ir.e PRESET _CH01CES.SCF.EEN 1 /► a2 */ tl-ϋt'T in f i i , _L r li J I

IΦde in 1 NSER .BIL .SCREEN 3 ' > aώ -*

#de. irie ΛLL.CAbH.IN.ΞCKEEN 4 - + aB *•' ttdefir.e CARD.TYPE.ΞCREEN 5 /* alυ */ tdefine PETRO.CARD.TYPE.SCREEN 6 /* al2 */ ttdefir.e INSERT .CARD.SCREEN 7 /* al4 */ ttdefine STANDKY. AUTH SCREEN S ■ a lft * ltd.? f j r.e f 'R'JCILEO FO.F JLL '. GREEN - - - J •- ' " ' -

Φ.ri.-. _ n._ r-'L-L b ! :- i..,. : l - 1 -.' il '■! Il * - aC . L.J l<> .* " >

— -2-CD ( -r -

ttdefine THANK.YOU.SCREEN 11 /* a22 */ ttdefine LIFT.FOR.KIDSK.SCREEN . 12 /* a24 */ ttdefine THANK YOU KIOSK SCREEN 13 /* a23 */

ttdefine PUMP . OUT.OF.ORDER.SCREEN 14

# e ine B D . NOTE . SCREEN 15 ttdefir.e POWER.OFF.RECEIPT.SCREEN 16 ttdefine PRI TER.BROKEN.SCREEN 17 ttdefine CARD.REFUSED.SCREEN IS ttdefine HOT.CARD.SCREEN 19 ttdefine PUMP.OR.ELSE.SCREEN 20 ttdefine NON.MAG.SCREEN 21 ttdefine KIOSK.HALTED.SCREEN 22

Φrdefine BAD.CARD.SCREEN 23 ttdefine REMOVE.CARD.SCREEN 24 ttdefine REPLACE.NOZΣLE.SCREEN 25 ttdefine 0THER.CARD . 3CREEN 26 ttdefir.e SYSTEM.PROBLEM . ΞCREEN 27 ttdefine RECEIPT STANDBY SCREEN 28

appl /select .grade. c

ttinclude "vars.h"

select.grade (hose) char hose;

\

T — gr ad .μ um ed = f-cC'de.dracJf - (UNCHAR ( ho&e/ . ! do. spl ay.grade (dave, T— g r ad e_ρ umped , T- -1 anguage) ;

appl/send.headers.c

ttinclude "vars.h"

static int cnt ram loadedϊ

send cnt header.

int i; char *e,

*cnt_string( ) ,

*h;

i ( cnt . ram.o.. ( ) ) return ~

et.receipt . headers ( ) for ( i = 0; h = cnt_string( i ); i++ ) r

cnt.ciTid ( dave, h, 10 ); new event ( δ.e , CNT EVENT ) ;

set cnt ram loaded ( )

cnt ram reset ( )

.- cΛ.li J. l_ t |_.__fc_.U — •- ■• ' .

-- 2 _.cn -

set cnt ram loaded < )

cnt.ra .loaded = 15

c n ' r a r. ■ k (

return cnt ram loaded;

appl /strings. c

ttinclude "vars.h"

char -*credvouchs ()

- return "STATION ID"?

char -K-carvouChs ()

return " " s

char -s-carwashs ()

char *ρumps ()

return T->language == ENGLISH ? "PUMP NO." _ "POMPE NO.

char -κ-ampms (h) int h;

if ( h >= 12 ) return T—> ' iangL.age == ENGLISH V else

-2.09-

return T-..language == ENGLISH ? "AM" : "A";

static char degrades I 1 = C "REGULAR", "UNLEADED",

"SUPER UNLEADED" 3-5 static char *fgrades CJ = C "ORDINAIRE", "SANS PLOMB",

'SUPER SANIΞ PLOMr:" j

char ^grade (g)

r

g • if ( T- language == ENGLISH ) return egrades CgD; 'else return rades C ς- 31

char *! 1 tres < )

. t Lirn L cii i ciu- — —

ENGLISH "QUANTITE ACHETEE'

char -M-uels ()

return T- language == ENGLISH ^ "FUEL" : "CARBURANT"

char -*totals ()

return T- 1anguage = ENGLISH ? "TOTAL" : "MONTANT DU";

har _sh- ()

-etLirn /language == ENGL 1 LASH TENDERED" IOMT:

char -s-credits ()

return T- 1 nguage == ENGLISH ? "CREDIT DUE" : "CREDIT";

char *thaπkyαu5 (>

return T->1anguage == ENGLISH ? "THAN -YOU" : "MERCI";

ι_h_:ir -v-card names . )

;.wi _.h ( 1— i___r d.type

case PETRO.CARD: return "PETRO*"; break; case VISA.CARD- return "VISA#"; break; case MASTER.CARD. return "M.CARD#"; break; de-fault; retur.. "U W 1-. " ; brea!. ~

recei pt.card. ield ()

switch ( T-'card.type )

case ISΛ.CARD: return 53; break; case MASTER.CARD: return 52; break; de-faults return 54; break;

-credtraili

return "HELLO"

ι_hai as ι_rai Is i

retu

static char __ C 40 D:

char *card -formats ( )

- 2-I T - -

char * = 1->card_πu.τιber;

switch ( T—>card.type )

case PETRO.CARD: p += 5; tsprintf (s, "%3.3s-%3.3s-"/.3.3s-7.1. is-7„4_4s" , p, p t' 3, p -'- 6, p ÷ .. p t i _;; ; break; case VISA.CARD: tsprintf (s, "7_4.4s-7.3.3s-7.3.3s~"/C3.3s" , p, p + 4, p + 7, p + 10); break; case MASTER.CARD: /* HACK - don't know yet */ ' tsprintf (s, "7.4.4s-7.4.4s-7-4„4s-7.4.4s" , p f p +- , p t- 8, p- + 12) break ; def aul t : strncpy (s , p , 12) ; break;

return s;

char -*types_string ( type ) unsigned type;

char *ts;

s itch ( type ) r

case CARD.TRANSACTION: ts = "card"; break; case CASH.TRANSACTION: ts = "cash"; break; case POST.PAY.TRANSACTION: ts = "post pay"; break; def u11Ϊ ts = "unkno n" ; b ea ;

re urn t ;

*

appl/strings.h

char *pumps () ; char *gradeε(); char *litres (); char *fLiels O ; char *totals () ; char *cashs () ; char *credits (); char *than yous (); char *card_names (); char *card_formatsO ; char -x-ampiTis O; char *credvouchs (); char *ca vouchs .) ; char *carwashs (); char *credtrails () ; char *waεhtrails ();

--Z

appl /trans. h typedef struct C unsigned yea , month , day, hour s. „ iT.J. nutec ;

ttdefine MAX CARD LENGTH 50

tvpedef struct C unsigned t pe; h i _u-d.nuii.DPr MAλ_CARD_LENGTH-1 J, auth.nu ber C MAX.CARD.LENGTH 3; char respoπse.codeC 2 3; char 1 a iLiage.code;

_ .Ci ~j~l 'd C ' ji- cl L-.'pe;

1ong •/ol ume . pu ped ; - illing data ur.siqneα cer. h ->__ ' imped , ρrιce.pumped, preset.amount , grade_pumped , pump _id_pumped; i i j j ! ι_ri'i i i-i > _. >: -

UI I . L -(I I l_' I \ t-l ! I -

car.wash.amoun , t ans.seq.nu , total.due, change.due, l nguage; Lirisigned Ltπieadεd.price, /* ri es -".- regul ar.price, premium.price; * transaction;

_2.n-

appl /tn m. c char *Fιrst_non_bl an.: ( s ) char *s;

:har -*ρ

return ρ

char *Last_noπ_blan . s ) char -*s;

r —

5 P D — 1

eturn p:

char T I ' ri m ( __• ) char #55

char -*f ,

÷-i

- 2^

f = First.non.blank ( s ); 1 = Last.πon.blank ( s );

len - 1 - f + 1; memcpy( s, f , 1en ) ; __-£ 1en J = ' \0 " ι-

return s;

appl /type.of .card. c Φ. include "vars.h"

* ttinclLtde "screens. h" ttinclude "exceptions. h"

«

I y e . o t . c r d.choice( )

char *e;

stop.video.show ( ); show.screer.. dave, CARD.TYPE.SCREEM );

Set.user.entry ( card.choice.audio < T->language ) ); new.event . ξ.e, SCREEM.TOLICHED );

Set__ . u-__s.r_e>.it ( ); switch ( *e ) "r_ case 'R's return 0; break; case 'T': longjmp . transaction.trap, JUΞT.RESET.ME ) ; bre case 'P ' s return Type.o .petro.card ( ); break ; se 'M ' _ se " v ': ii return 1; brea ; case 'G': longjm ( post.pay.trap , OTHER.ACCEPTED.CARD return 1; break;

— '2-'2- ? — appl /type.of.pet.

#include "vars.h" #include "screens. h" tinclude "excsptions.h"

Type.of.petro.card < )

stop.video.sho ( ); show.screen . dave, PETRO.CARD.TYPE.SCREEN );

Set.user.entry ( petro.card.aLidio ( T-.--l nguage ) ); new.event . _.e, SCREEN.TOUCHED );

3et_user_e>.it < ) ; switch (*e)

-rfSfcr P. ϊ return .__; break; case 'T' longjmp ( transaction.trap, JUST.RESET.ME ); break;

brea ; case •' £:'_ longjmp ( post.pay.trap , NON.MAG.CARD ); break;

-.-7/1.1-

appl /vars. h

#i fndef GBLGEN

#define VARIABLE extern

.. J se ..ri"-_ι i

ttinclude se π.p.h ' ttmclude "' -events/even , h" ttinclude "trans. h"

ttdefine ONE.SECOND_AND_A.HALF 30 ftd f-f i r. e F I VE_ SECONDS 1 O

#d e f 3 n e ONE.T WENT I El H

tide-fine UNCHAR .b) ( (b ) - ' »

ttdefine UNDEFINED.TRANSACTION 0 ..define- CAEH.TRANS C I ' ION L

..d . , ,,__ .Y-iRD.rRΛIMSAC-TICN : ttdefine- POST _PAV_ TRANSACTION Z

VARIABLE unsi gned debug.event ;

VARIABLE υns_ gned dave;

extern char *cards name <)

: ri'i i '. ' 1 - ι i 'i i

-τn-^'

.previous, *T, *P;

VARIABLE date and time now;

#d. -ine Mr ' CEN " ^oυυ * Φfc'O.OO limit *.

VARIABLE char -*Daves_error_statu.s: VARIABLE JiTip.buf ^transact! on.trap , *post_ρay_tra ;

/* receipt headers */

ttdefine HEADER.LENGTH 40 ttdefine HEADER FILE ' /dave/receipt.headers"

.ypedef int (*PFI) ();

/* filling outcomes */

ttdefir.e NORM L.FILL ttdefine SYSTEM.ABEND ttdefine USER ABEND

appl/video.receipt.c

ttinclLide "vars.h" ttinclude "strings. h"

video. receipt O

•_. char s lκ.ι j ,

#heade 1 O ; date.and.ti.Tie t = " ! - Lti e; int hh — t. hours;

displ ay.str-ing.centred ( dave, headerl . ) , 308, 468, 329 );

tsprintf ts, "Il7.ι " )5u" , T- trans seq.nu ) ; displ ay_ string . clave, s, 318, 232 ) ;

. f < hr. == 1 ) hh -= 12;

tspr l ntf ( _. H " "'. d Ϊ v.02d"/.s " , hh , L . mi nutes , ampms ( t . hours ) ■ ii'Ξpi M ..-.-i" 1 " -i I'f'f v iJ ' J t 5 , -. + 1 ϋ> , 282 ) ;

tsρr_ n L l < - . ""_ .> " J "..'2.: - °.ϋ2d " , t . on th t , av „ t _ ear ) ; display.stπng (dave, _. , 313, 2ό9) ;

tsprintf (s, ""/.s7.d", pumpsO , T- pump.i d.pumped ) ; display. string (dave, s, 403, 269);

'c<_.ρr_r..ϊ . ""_ * _-" , oi a e- ~ ( I- iire-de r'ii.ι.r.F---r- > ;; d I l * l _ L l'_ =. I • i i I' I " i -l'

tsprintf (s, "7.2d.7.d*" , T->price.pumped / 10,

T->price_pLimped 7.10) ; display.string (dave, s, 430, 232);

display.string (dave, litresO, 318, 217); tsprintf (s, " .31 d.7.021 dL" , T->vαlume_p umped / 1O0L,

T - ' v o 1 u rn __ u L" in D e d .-» 1 V ' > . ; display.string (dave, s, 417, 217);

display.string (dave, fuels() , " 318, 195); video.dollars (s, T— >cents_pumped , 417, 195);

display.string (dave, totalsO , 318, 181); video.dollars (s, T->total_due, 417, 181);

if (T->type = CASH.TRANSACTION)

display.string (dave, cashsO , 316, 167'); video.dollars (s, T—>cents_in, 417, 167);

if ( T—>change_due != 0 )

display.string (dave, credits 1 ;) , 31S, 153); video.dollars ≤, 1 .s-chanqe . dL'. , 4i. , 153) ;

if (T->type == CARD.TRANSACTION)

- 1 _..*__.' . ΛI~d I'd , ■ 4ώfc» _, _i L

- 22≤ " -

Ji api te'ϋ -.i a.Y .., I .ι..fιi- V U 1 - % _, UI Λ ( j> ϊ -■ H J 1 'V )

video.dollars (s, amount, x, y ) char *s; unsigned amount, :. , v; r

tspr lriL-f ,s, "J." 7.2J . "_02d " , _-.im_._ir.l_ . J Ou , aι.<πur.-i "'. 100 ) ; display.string (dave, s, .; , y ) ;

l dε.o_ι_ard *>£., ,.1. .c2, y- char *-ε; unsigned :ι 1 , ..2, y; r

tsprintf (ε,"7.s%ε", card. names () , card.f or ats ( ) ) ; display.string.ceπtred (dave, s, ;; 1 , x2, y) ;

car wash choices ()

*

-X2b-

blink/blink. c

nclude <timer.h>

#include <stdio.h> ttinclu.de < mag i c - h > ftiπciLi e "blink, h"

ttdefine HALF.SECDND 10

unsigned dave;

ttdefine HIGHLIGHT O ttdefir.e NORMAL 1

main (argc, argv) int argc; char *argv C3; r V request r; Linsigned task;

initialize (argc, argvCl );

displ y.ini t_ar row (dave) ; while (1) " r*__. task = RECEIVE_ANY(S.r) ;

REPLY (task, S.r) ; link ( task , s.r} ; / -K re urns whet- cr _■_ t ._ ve i r- f _.it-_ ! d _ive ) .

REPLY (tas S<r)

initialize (c, dn) l π L c ; char -i-dr. ; r

dave = *dn - '0 ' ; i ( c != 2 ) tfprintf (stderr, "blink dave.number\n")

unsigned b;

blin. itas. , r ) unsigned tas. ; request *r;

while (CRECETVE(ta_- -= U >

if (b == 0) « displ ay. arrow (dave, O, O) ; if (b == 7) di <=ρl av_ reset.arrow (dave) ; ..- * it _ . iiiif. ', " . J I L.r, _ '..-.! E 'I 'I RLI.A Γ I .'I. , ! .HI ι : _ " . " f " L ι| ' - h-n- ,

if (b == S) b = 0:

-Z-2P.- bl in /bl ink. h

ttinclude " /user /steve/dave/dave. request . h"

ttdefine BL1NKERS.NAME "/dave/bl ink"

H .-.n* ULJNl 1

blink/blink.map

. Segment: 1 OOOO to 06F6 (1783 bytes) .Segment:2 OOOO to OOBA (187 bytes) .Segment:3 OOBB to 0168 (174 bytes) .Total size is 0S60 (2144) bytes ι_υ. proioj .e epilogue stk.overflow

<e>.it>

ΦLicbeg

-.mai n ' >

<ini tial ize>

<biink>

< d i s 1 ay.ar row >

<. d i spl. ay.r eset.a r ow _

< d i s 1 ay. i n i t _ar row >

< sl eep <abs_sl εeρ>

< d r eg i ster_π aπie >

< c lloc > <malloc> <real loc> •; . -t e^

C 1 0549 <fopen>

COI 054F <fclose>

* COI 0555 <getc>

COI 055B <putc>

_.

*- COI 0561 ungetcj-

COI 0567 f flush "

CO L 056D Cl-ipπnt .

CO1 0573 <ts rintf >

COI 0579 -.fget.-

COI 057F <fput>

COI 0585 <fiseek>

COI 058B rewind>

COI 0591 .forwards

COI 0597 '.breakable.:-

COJ. 059D .st rnat -

COI 05A3 <strcmp>

CO1 05A9 <strcpy>

COI 05AF •-.strlen:-

COJ U5 5 -.send

COI 05BB -..abort.-

COI 05C1 • .unbreak ble: ; -

COI 05C7 <vc_send.reply.

COI 05CD <vc_create>

COI 05D3 <vc_create2>

COI 05D9 c_create3:-

CO .. 0 ~~ _>DF . k . s>: de str o o 05 ..I e i _= . i v f.'i

— irzn--

4

COl 0687 <creceive>

COl 06SD <memcpy>

COl 06SD <copy>

COl 06BA <zero>

COl 06D6 <rnemset>

D00 0000 <User_sp>

DOO 0002 <Us r.ss>

DOO 0004 <Exc_bits>

DOO OOOS <Exc_al 1ow>

DOO OOOC <Exc.pending>

DOO 0010 E c_fp>

DOO 0012 <Exc_pc>

DOO 0014 <Exc:_permit>

DOO OOIS <Exit_status>

DO0 001A <Error_status>

DOO 001 <My_tid>

DOO 001E <Dads.tid>

DOO 0020 Eireak_count>

DOO 0021 <My_tty>

DOO 0022 stack.base

DOO 0024 <Cmd_f1 gs>

DOO 0025 <My_priority>

DOO 0026 <stdin>

DOO 0028 <stdout >

DOO 002A <std rr>

DO 002C <Free_list>

DOO 002E <End of free>

- 2.34--

<File_list> _Argc>

<_Argv> stk.li it

SAVE

TEMP

<Code_flags>

<User_nurn>

<Grou _nurn>

<Team_nurn>

<My_nid>

<Dads_nid>

<My_tty.nid>

<My.cd_πid>

< Rel ease_rιLim > <Ndp_save_area> <Fstack>

<Cal 1 _stack_ptr >

< Seg men t _ t ab 1 e . p t r <Check_poi nt . sp >

< User _sρ ar >

<Qdb_tid >

<dave> <b >

DO . 00C1 -.or

blink/int/blink int.c

#include '" " -blink,h" #include task. sgs.h> ttinclude <magic.h

static unsigned b inker; extern request dr;

start.blinker (dave) unsigned dave; C char daves C 2 3;

daves C 0 1 = dave t '0';

>- daves C 1 3 = '\0'; blinker = create to, PUIM.COMCURRENT, l v iv_ pr_ oritv , υ, 0,

BLiNKER3.NAME, dave , 0) ?

b1ink on ()

dr .opcode = BLUM.-; SEND (blinker, S.dr)

blink off ()

ul O Cn " ' Mil GLIM.

BLMD(b. ml c i ..di )

--2 -

blink/make ile

CFLAGS = -S

blink: blink.o linkobj blink.o c=blink m=b1ink. ap l=/user/steve/dave sort blink.map f=l,2 ! copy >blink. ap coρy 1i k /d ve/b1 i k

blink.os blink.c

bul 1 ch/bul 1 och . c

ttinclude "vars.h" ttinclude <timer.h> ttinclude "excepts.h" ttinclude "const. h"

__. t a t i c u n s i g n e d t a s ;

main( argc, argv ) int argc; char *argvC

.r * . request r; unsigned code;

if (code = setjmp( initial.trap )) initi l.error ( code ) ; else initialize (argc, argvCll, argvC2 , argvl.33 , argvC43);

for ( ; r, )

_r

task = RECElVE.ANYi _.r );

* if ( (task >> S) == my.port )

* Ti er.fired ( > ; else

- ~ 7yy%~-

REPLY( task, &r );

cal ler

returπ task

initialize t'argc, device . name, port, pump.device, lets.debug) int argc; char *device.name, *port, *pump_device, *lets_debug; \_. if t ' argc != 3 _.?. argc . - 4) usage ( ) ; log . bullocht "start" );

my .port = atoi ( port ) ; if ( attach ( iTiy.port ) 1= 0 ) longjmp ( iπitial.trap - NO.THiER > s.

if (argc * == 4 ) debug. = strc p ( lets_debug, "+d" ) == 0;

disallo ( ) ; bLilloch. in = my.open ( device.name, "rv", ini tial.trap ,

NG . DEVICE ) ; bullo h.out = •Tiy . α en ( device . name,, "wvu", initial trao,

NO.DEVICE ) ;

Set.his.sequence< ' ! ' ) ; Set.sale.complete( ) ; flush.input( bulloch.in ); init.hose.totals ( ); log.bulloch ( "ready" );

Set.my.ti er ( 1 );

initial.error ( code > unsigned code; r

char *message;

switch (code) • _ case O.TIMER: message = "no timer port"; break; case NO.DEVICE: message = "no device"; break;

.

log.bulloch ( message ); exit ( 1 ) ;

«

usage( )

tfprintf ( stderr, "bul 1αch bul 1och.device port, pump.devi e +d\π" ) it < 0

— -2- o -

bul1och/bLil1och.h

ttinclude "/user/steve/dave/dave.request.h"

ttdefine OPEN 1000 ttdefine CLEAR.PRICE.CHANGE.PENDING 2000 ttdefine L0AD . T0TALS 3000 ttdefine KI0S .AUTH0RΪ2ATI0N 4000 ttdefine KIOSK PAYMENT 5000

ttdefine GIVE.ME.TIMESTAMP ' ! ' /* 0x21 */ ttdefine GI E.ME.PUMP.MAP ' " ' /* 0x22 */ ttdefine I.NEED.ATTENTION 'tt' /* 0x23 * /

/* 0x24 ' $ ' i s OPEN -*/ ttdefine I.HAVE.A.HOT.CARD "/. ' /-* 0x25 -*/ ttdefine TAKE_PUHP_FRON_ME " \ ' ' /* 0x27 */ ttdefine RESET.Y0UR3ELF.PLEASE ' ( " /* 0 23 */ ttdefine HERE.IS.TIMESTAMP ' ) ' /* 0x29 -*/ ttdefine HERE.IS.PUMP.MAP ' * ' /* Ox a */ ttdefir.e RELEASE CARD PLEASE ■_'H __.L * ""-"

ttdefiπe CH NGE.PRICES . PLEASE 'G' ttdefine GI E.CREDIT.TOTALS 'X' ttdefine GIVE.CASH.T0TAL3 'Y * ttde-fine HALT.PUMP.PLEASE 'F' ttdefine HERE IS A TRANSACTION 'D'

-7. -1-

bul loch/bulloch. ap

.Segment: 1 0000 to 2573 (9538 bytes) .Segment:2 0000 to 0274 (629 bytes) .Segment:3 0275 to 0S09 (1429 bytes) .Total size is 2D7E (1164ώ>) bytes

C 1 005 proI.ogue

COl 005E epilogue

COl 0067 stk.overflo

CO1 007D exit>

COl 0083 $ucbeg

COl 0084 <main>

COl 01 IE <caller>

COl 012D -.initialize ' .--

CO1 01FA initia1_error •

COl 023F --.usage-

COl 0261 <Pushchar>

CO1 0271 •=: ' Nextchar>

COl 02E5 init.hose.total ..-

COl 0345 " hose.total '

COl 0372 :..seq totai .

COl 039E :.. hose.no >

COl 03CC <load_hose.total >

COl 0405 -.calculate.bcc^- COl 0437 Reset_inbound.:- CO 1 044F " i nboi i d. rf.-_ t - , eι I " C 1 ) 1 ΗA " '' iϊ'L ιι.essc.cι>-i

CO1 0571 <C1ear_my_timer> COl 0581 <Set_my.time s- Co1 05AA <Cancel_my_timer> COl 05DC <Delay> COl 05F7 <seπd_hose.total > COi 0σ2C <send.request.to.bul1och> COl 065C <bulloch_packet> COl 06F5 <transac * ti n_ρacket> COl 0771 <hose.tota1.packet> COl 07EF <Post_purr.p_map> COl 081C <Post_payment_made> COl 0834 -Post.release> COl 084C <Post.authorization> CO! 0864 <Post_halt> CO! 087C <Poεt.restart> COl 0894 <post.new_prices> C01 OSBD <Hook_down_event> C01 0941 <Set.hose.Lised> C01 0951 <Hose.numb r> CO1 0960 <His.sequeπce> COl 0970 • _Set_pLiiT.p_nLiff.ber COl 0930 <3et_his_sequence> COl 0990 <Decode_his_pump_aπd_sequence. COl 09B0 F'ump_number> COl 09BF <Set_status_pumpiπg> COl 09CE Set_ρump_hook.off ■ ■■ COl U9L.D -.c' _a__ X. pump sai& pendi g.--

-2¥ -

COl 09EC Set_sale_complete>

COl 09FB <Set_pump_-ri11ing_dat ' a>

COl 0A16 <Reply_to_status_poll

COl 0A2F <Reply_to_poll >

COl OADώ Reply.to.-fiJ.1ir.g_data>

CO1 OAEE. •R _ _Lo.autnori z ~~ - '

COl 0B09 <Reply_to.sale_complete>

COl 0B24 Acknowledge.control.messaged-

COl 0B3D KAcknowledge.price.prime>

COl 0BB6 <Nak_packet>

COl 0C33 <Process_price.change>

COl 0CC7 <_clear.price.change.pending>

COl 0CD7 <service_dave>

COl 0D5D --..hot.card. 1 -

COl 0D75 <.attention ' ;-

COl 0D90 <_pump_map>

CO1 ODAS <.timestamp

CO1 0DD7 ■■._transacti n>

COl OEOO Queue_requeΞt:.-

COl 0E2A -' " .kiosk.authorization •

COl 0E4F <_kiosk_payment>

COl 0E85 <_open>

COl OEA1 <_load_totals>

COl 0EF3 <Update,local.time " ; l OF44 :Po:_t_local time '

C'J Ϊ OP L ".'' . L Du t. SV - I" t i iii -.-

- A --

COl 1033 <Set_system_time>

COl 105C <make_qnx_ti e>

COl 10DF <get_qn>!_time

COl 10F8 <Timer.-fi ed>

COl 1143 <Send_queued_request>

COl 1183 <Accept_CDntrol_iT.e5s.age>

C01 11AB <Accept.liπk_response>

C01 11F3 <Process_control.message

COl 1241 <Emulate_pump>

COl 12AC <bulloch_event>

COl 12C6 <coπtrol.even >

CO1 12E0 <price.event>

COl 12FA <lαg_bulloch>

COl 1311 <event>

CO! 135A <lrequest>

COl 13B2 <disallow>

C01 13D1 < y.open>

COl 1 04 <tsscan-f>

CO! 1A44 <sleeρ>

CO1 1 SA <abs.sleep>

COl 1AAF <set.timer>

COl 1B16 <strncpy>

COl 1B50 <strncat>

CO! 1B89 <strncmp>

CO1 1BBC <-F1ush_input>

CO l 1 C1B <dreqi ster.naiTie >

C 1 1 DC 1 < -P i n d a m % n >

COl 1E2B <char_waiting>

COl 1ED4 <calloc>

COl 1EDA <malloc>

CO1 1EEO <real1oc>

COl 1EE_> <-free>

COl lEEό < ree.>

COl 1EEC <-fopen>

COl 1EF2 <-fclose>

COl 1EF8 <getc>

COl 1EFE <putc>

COl 1F04 <ungetc>

COl 1FOA <-fflush>

-COl 1F10 <t-fprint-f>

COl IF16 <tsprint-f->

COl 1F1C <fget>

COl 1F22 <fput>

COl 1F28 <-fiseek>

COl 1F2E <rewind>

COl 1F34 < or ard>

C0 IF3A <break b1e>

CO'l 1F40 <5trcat>

COl lF4ά <strcmp>

COl 1F4C <strcpy>

COl 1F52 <strlen>

COl 1F5S <seπd>

COl 1F5E <abort:-

- itJo-

COl 1F64 <unbreakable>

COl 1F6A <setjm >

COl 1FCF <longjmp>

COl 203D <nargs>

CO1 2053 1epi1ogue

CO 205C I ul

COl 20AB Imodr

COl 20B4 l od

COl -20BA ldivr

COl 20C3 ldiv

COl 217C <vc.send.reply>

COl 2182 <vc_create>

COl 2188 <vc_create2>

COl 21SE <vc.create3>

COl 2194 <ker_vc_destroy>

COl 219 <def.server>

COl 21A0 <set_acc_tlags>

COl 21Aό <set_exception>

COl 21B2 <hold>

COl 21BS <uπhold>

COl 21BE <time_slice>

COl 21C4 <task_info>

COl 21CA ■• .-force_ready>

COl 21D0 <set_priority>

CO! 2 Dά <set user

« 1.

π n n n n n o o n π π n n n n n n n π n n π n n o

J3 13 13 13 1.1 3 13 13 .3 13 t3 13 r-J 1-3 13 13 13 13 13 \3 10

I .3 1-3 10 r.ι 13 13 13 13 13 l-J .3 tJ JJ 13 J3 1-3 13 13 rπ π 3 ω LI s -H J '.J 10 13 cπ o ω 43 rπ ω rJ n 3 4J m ro 13 O

UJ

* τ

I

COl 2379 <i5alnum>

COl 23B8 -.isascii >

COl 23D1 iscn l >

COl 23F3 <isprint>

COl 2415 <isκdiqit>

UϋO OO1'

DOO 0 14 <E;-.c.ρer.τιit> OO 0018 <E.-.it.status>

DOO 001 <Error_st tus.

DOO 00IC <My_tid>

DOO 001E <Dads_tid>

DOO 0020 < Etr e a k _c our. t >

DOO 0021 <i v iv tt v :-

DOO 0 2__: ' stack base

DOO 0024 <C d.f1ags

DOO 0025 <My.priority ' .:--

DOO 0026 <stdin>

DOO 0028 <stdou >

DOO 002A stderr>

DOO 002E -.Er.d.of_tree

D0 0030 <Fi1e_1ist>

DOO 0032 <_Argc>

DOO 0034 stk.li it

DOO 0034 <_Argv> OO 0036 SAVE OO 0038 TEMP OO 0060 •'.Code_flags ' -- OO OOfal <User_num:- OO 0062 <Group_num> OO 0063 -::Team_num> OO 0065 < My _n i d ' ..- OO 0069 :;M- _tty_nid. OO 006B <My_cd_nid::- OO 006D <Release_num> OO 006E <Ndp_save.area> OO 0070 <Fstack> OO 007. "Call.st r I μ^r U 00 "7 .& eg men I l .ih Jt- pt.'

- zso-

— 2--S.-

bulloch/c iles

bulloch.c chars.in.c globals.c hose.total .c in ounds. c my.timer.c outbound.c post.c price_change.c pump.emLtl .c service.dave.c system.ti e. c timer fired.c

*

-

bulloch/chars in.c

#include "coπst.h" ttinclude "vars.h"

#define STACK_EMPTY -2

stati int _

Pushchar ( c ) int c; -C stack = c:

Ne.- * tchar ( >

int t = TIMEOUT;

if ( _stack 1= STACK.Ei PTY ) /* try the character stack -*/ r

.stack = ST CK.EMPTY; return t«

if- ( cnar_waiting (bulloch.iπ) ) /* then try com channel */ t - getc (bulloch.in) _. 0x7f;

- 2S3-

DelayC CHARACTER.TIMEOUT ); if ( char.waiting (bulloch.in) ) t = getc (bulloch.in) S. 0x7f;

J

_c

* return t; .

bulloch/const, h ttdefine HALF.SECOND 10 ttdefine TEN.HALF.SECONDS 10 ttdefine FIFTH SECOND 4

ttdefine STATUS 'S * LTS command codes */ ttdefine DΣSPLAY.DATA "D ttdefine MOTORS.ON 'N

" .define MOTORS.OFF 'F ttdefir.e AUTHORIZE 'C ttdefine SET.PRICES 'G' ttdefine READ.PRICES 'B' ttdefine OPTIONS 'O ttdefine PRE_PAYMENT 'E' ttdefine PRE.PAYMENT.STATUS 'R ' ttdefir.e CLEAR.REΞTART 'P' ttdefine SET_SALE_COMPLETE 'T'

ttdefine LTS.COMMAND.LENGTH 1 ttdefine BULLOCH MESSAGE LENGTH ~

ttdefine OFF.HOO κ OO1 / * Bi- ttdefine ON.HOOK (""OFF^OOK) ttdefine MOTOR.ON Oκ0002 . ttde ine FUEL.FLOWING Ox0004 ttdefine MANUAL.MODE 0x0008 ttdefin& SALE.CGMFLETE OK0010 ttdefi.!„-. POWER UP 0κ 1 0

- 25^-

ttdefine PRODUCT_ERROR 0x0200 ttdefine TEMPERATURE.F ILURE 0x0400 ttdefine PULSER.F ILURE OxOSOO ttdefine LOCAL.PRICE.CHANGE OxlOOO

ttdefine LTS.TI EOUT . O.sOOπl LTS error bits */ d xr.i-. ' LTS_fESSA5t__L r r-l l h ' ΉΌ_' ttdefine LTS.BCC 0x0003 ttdefine LTS.SEOUENCE.RANGE 0x00 4 ttdefine LTS.SEQUENCE.MATCH 0x0005 ttdefine LTS.ID 0x0006 ttdefine LTS.CONTEXT 0x0007 ttdefine LTS_UN!-'NOWN 0x0008

ttdefme LTS.AUTH.INVALID Ox0001 ttdeflne LTS.PUMP.ON_IN LID 0-.0002 ttdefine LTS_NO_PREPAY 0x0003 ttdefine LTS_NO_PRICES 0x0004 ttdefine LTS.BAD.DATA OxoOOS ttdenr..- LI 5 DATA .. EJECTED 0 nnC, L -

ttde in-. TIMEOUT - J ttdefine MAX.MESSAGE SO ttdefine ACK " Ox06 ttdefir.e END 0:ι05 ttdefine STX 0 02 ticlc-i l e M . 0 LL.

..d__t i nc j D L

_^<S ( o-

ttdefine CHARACTER.TIMEOUT ttdefine IDLE.INTERVAL /* half second */

ttdefine NHOSES ttdefine LDST.PUMP 'L' ttdefine BAD STATUS

ttdefine UNCHAR(b) ((b) - '0') ttdefine TOCHAR(b) ((b) + 'O')

ttdefine IDLE.STATUS CD' ! SALE COMPLETE) ttdefine BASE.STATUS '_- ttdefine I AM BUSY 0x 0

ttdef i ne IDLE STATUS STRING "Tn"

- l- bul loch/excepts. h

ttdefine NO.DEVICE 1 ttdefine NO.TIMER 2 ttdefine NO.STATUS ttdefir.e NO.PRICES ttdefine USAGE

ttdefir.e ND.DISPL Y.DATA ttdefine NO.PUMP <_. ttdefine NO.PRESET 7 ttdefine ND AUTHORIZE 8

bul 1 ch f unc . h

unsigned lts.status O , lts_display_d ta O, .1 t s.gασd.rep 1 y ( ) ;

char -κ-lt5_command (),

-*lts data () ;

bulloch/g1obals.c ttdefine GBLGEN

ttinclude "vars.h"

bul loch/hose total. c

ttinclude "vars.h" ttinclude "const. h 1

typedef- struct C int noseid" char dataC 27 3 ; / * 25 + eo≡ t spare */

3 total;

total totals C NHOSES * 2 3;

ini .hαse.tαtals ( ) r _ z era '• totals, _- * _ .-eof ' tι>. ■=.] =• ' ■ ) ;

totalsC υ 3.sequence = 'U ' ϊ totalsC 0 3-hoseιd = 1; totalsC 1 J. sequence = 'V ' tύtalsC 1 3. ho e d - _ ι

-ϋtii 1 ?T __ .! _ I-fiiV-'Cπ .- — .'1 ; totalsC 2 J.hoseid - 2, totalsC 3 3. sequence = ' X ' s totalsC 3 3.hoseιd = 2; totalsC 4 . sequence = 'Y ' ; total-: r 4 1 n-= α rl

-2-bO-

totalsC 5 3.hoseid

hose.total.pending = 7;

char -K-hose.total ( i > unsigned i ;

l — return totalsC i 3. data;

seq.total ( i > unsigned i;

return totalsC i 1. sequence:

hose no r.signed i

return totalsC i 3-hoseid;

load.hose.total ( i, stuff ) c a - *-_tuff;-

i — 5

COPY SAFELY ( totalsC i 3. data, stuff )

_.-2_b3--

bulloch/inbounds.c

#include timer.h> #include "const. h" #include "vars.h"

int 15

register unsigned char bcc = 0; register char *p = m;

for ( ; 1 ; 1— ) bcc - "* = -H-p-t-t;

return bcc;

Reset inbound ( )

:ero( inbound, sizeof ( inbound ) )

Inbound.received ( data ) char -*data;

_ ni ι .

*data = 0; /* assume failure */

for ( i = 0? i \ 20; i++ ) /* look for start of message */ switch ( c * = Ne.ctchar ( ) ) r

case AC! s case NA : case STX: return Get.rr.essaqe ( c, data ' \ break; default: break;

return '.'.

e .iTiessc.qe l c, data ) int c \ char *data *

lnt bcc ι ., num chars

bcc = c; /* initialise bcc -*/ *data+t = c; /* save start character */ for ( i — ■") ;, x -_. ..- _. ' - OE.L * ■ -

. f . ' . i-lf t er ' r i hF: ϋi π .

if ( num.chars > * - ** MAX.MESSAGE ) /*- don't overflow */ return 0; /* message is too big * / el

*datatt = c; * just store the character * bcc - " - * = c; * update bcc * nuiii_chars++ * /* update chars rec ' d count */

else /* timeout and count it */ i-M-;

if ( i -=-= 20 ) / " * - must have timed out */

Set.his_sequer.ee ( inboundC 1 ? inboundC 1 3 _ ' ! ' ) Nak_packet( LTS.TIMEOUT ! BA3E.3TATUΞ, BAΞE.STATUS ); return 0;

if (bcc != ex char C) >

Set.his.sequence ( inboundC 1 3 ); ak_packet( LTS.BCC ! BASE.STATUS, BASE_STATUS .3 return 0;

else return 1 ;

*_•

— '2- (_> © -

bul1och/makefi1

CFLAG3 = -S SOURCES = Scfiles OBJECTS = ©objects

bul 1och . $■ (OBJECTS ' )

1 iπkob j c=bul1och x=objects s=2000 rr-= * bul1och. map

1—/user/steve/dave sort bul loch, map f= * l,2 ! copy >bulloch. map copy bulloch /dave/bulloch

globals.o: vars.h

— 2bH-

bulloch/ y.timer.c

ttinclude "vars.h" ttinclude < ti er. h> ttinclude "const. h"

static int timer runriinq:

Clear.my.ti er ( )

ti er. running = 0:

Set . m/ . ti ei" ( ticks ) unsigned ticks; r

set_timer( TIMER.SIBNAL, RELATIVE, ticks, O, my .port ) timer running = 1.

Cari t-1 i er ( l

if (ti er .running) set_timer( TIMER.CANCEL, 0, 0, 0, my.pαrt ) 3 ti er. running = 0;

υε_ L i c. i

- bS

set_timer< TIMER.WAKEUP, RELATIVE, ticks ) ;

bulloch/objects

bulloch. o chars.in.o g1obals.o hose.total.o inbounds.α my_ti er.o outbound.o post. o pump.emul .α prlce cha ■qe= c service_dave.o syste .time.o timer fired.α

bul loch/outbound.c

ttinclude "vars.h" ttinclude "const.h"

unsigned char calculate . bcc < ) Ϊ

unsigned ht: r_ char -*hose_total.packet ( ) , *hose_total < ) ,

*P5 ' int length;

p - hose.total.packet ( hose.total ( ht ) , seq . total ( ht ) , hose_no ( ht ) , ?..1 ength ) p /* fput ( p, length, bulloch.out ) ; */

send.request.to_bulloch . r ) char r;

,r

char *bul 1 och.packet < ) ,

i n t j. ti p. 3-i t

p = bulloch.packet ( r, outbound.data, ..length > ; fput( p, length, bulloch.out ) j

static char packet buffer E 200 3;

int *1 ;

register char *c = .packet.buffer5 char *transaction_packet C );

zero! _ρacket_buffe , sireof . .packet.bu fer ) );

if . opcode ***■ = HERE.IS.A.TRA SACTION ) return transact!oπ.packet r . data, i ) 5 else

*c+÷ = STX? * start of packet */

-s- -i—f- — His_sequEr.CBl .' 5 / • ■ sequence number £ -* + — i CHAK: (F ιτ.ρ_ number . ) ) 5 ' «- id tield - Dum * / *c++ = TQCHAR .0/ ;s * id field - hose */

s-c+t- -= opcode; while (-κ-data)

*c++ = *datatt *

÷-.::-1—f- — .__aI.c■_.1 _• t bcc . Dacket h- ' -ter ,- c -- p c e Putter-

- zn ι - -

• 1 = c - _pac. et.buffer; return .packet.buffer;

cπar T t. an_-.at_.tiori d t. 1 >

register char *c - _pac. et.buf fer;

*c++ = STX; /*- start of packet */

*c++ **** 'A' 5 /* sequence number */

* c tt = TOCHAR (Puriip. umber < ) ) ; /* id field - pump ■* / v-c------ = TOCHAR <Hose_number ( 11; /* id fi ld -- hose *.'

- ,-; h +• = ' <a : ' [ C - G status # '

* c ++ = ' e ' ; * f a! e status *•/ v-fhile (tdatal

*c++ = *riatatt *

— - F! ! efi c~ iiies "r»a i ρ -"C++ - cal ul ate_bcc ( _paci- t.buf fer , c - _pac. e _buffι_ * r J

■** i — C - _ pac. E' L _ LIT T _.Γ ,

-* return .pact- et.buf-f er;

:har > * hose_ total_ ρ<_-c. et ( data, sequence, hose, 1 )

register char *c = .packet.buffe ;

* c ++ _= STX? /* start of packet */

-x-c-fH- = sequencef- /* sequence number */

■if,---"-- = TOCHAR CPump number \ >); * id field — pump *

* + ~~~ l U HA v ϋSB) 5 -s- id field - nose « •"

.χ. c + - = '_'- /# fake status */

*c++ = '©'5 /-a- fake status */ while (*-data)

*c++ _=. *data+t*

* c +-r- = DEL; * end of message */

J tc- -t = calculate.bcc (.packet.buffer , c - .packet.buffer) ; *1 = c — .packet.buffer %

retu;—n _packet.buffer;

bul 1 och/post . c ttinclude "vars.h" ttinclude "const. h"

static char _buffer L .50 3;

P o s t __ o u r. p _ f D . ε char -*s;

tsprintf ( .buffer, "MAP7.3. ε" , s t 5 ); bulloch.even ( my.client, .buffer );

Post.pay ent.made( >

buJ 3 och event . Ill Y clien '. IDS. PAYMENT

Post release( )

il l ch e -ent :J ι e-n "RF * F-E r D"

Post author nation' )

bulloch.event < my.client, "flOS. AUTHORIZED" . ;

- Tnk--

control.event ( my.client, "HALT PUMP" ) ;

Post restart ( )

_ _. e.n—i:-. ii rh-,th— ιo—--I i /--.irh-.-ri- ri-.lL.ihι--i1_-_ι

post . new . prices( s ) char *s;

.r w tsprintf ( .buffer, "PRICES'/.s" , s ) ; price . eventC my.client, .buffer );

f -2-l≤ '

bull och/pπ ce.change. c ttinclude "vars.h" ttinclude "eκcepts.h" ttinclude "const. h"

static unsigned _change_perιdιngι ... t.-tic ch:ι _nei " _ρrices C 50 1°,

Procesε.pπ ce.change ( )

unsigned i ;

if ( _change_pendir.g == 0 ) r

Acknowledge.price.pπ e . > ; zero' _new_ρrιces, si eof . _new_ρπ ces ) >:

Reset.inbound ( ) ; for ( l = 0; Nextchar < ) '= STX ..!.- 1 20; ι++ )

if ( l =- 20 ) return; Pusr.char . STX . if ( nbound received' inbound . .

memcpy' _new_pπces, inbound + 4, 24 ); post. new.pπ ces ' .new.prices ) * change, penrh π - 1 "

else

Nak_packet ( BASE.STATUS, BASE.STATUS ) ;

_ρrice_chaπge_ρending ' )

_ch__r>ge_pendi ng

— lyi " ! - bul 1 ch • otocoJ

Touchcom - Etuiloch Protocol Draft May 2/S7 Steve Bond

lntro ucti n

Steve Bond and Pat keeping met on Feb. 14/87 to discuss the communication between the Bulloch and Touchcom systems. This is a summary of the discussion.

There 'are two requi ements.

_.- 1 FϋS .credit card;, etc. bl pump management

Th so-, tware protocol for pump anaqemefit shall be as similar a |_ .J __ __ L L 1 α t- * ι tht_ LTZ protocol '. _ r '< ~ <\ ~ w a~<~ pro I * e ru oi

PUS shall be as similar as possible to the Fetro Canada FOB protocol .

Pu p Management

--2^73 -

tdefiπe SIVE_ME_TIMESTAMP /* 0x21 * */ ttdefine GIVE_ME_PUMP_MAP / * 0x22 -*/ #define I_NEED_ATTENTION 'tt /* 0>c23 * */

'* /* 0x24 */ ttdefine I_HAVE_A_HOT_CARD V. ' /* O; 25 */ ttdefine BIVE_ME_PUMP -<' /* 0> 26 */ ttdefine TA^E_PUMP_FROM_ME \ ' ' /* 0 ttdefine RESET_YOURSELF_PLEASE C ' /* 0 28 * ttdefine HERE_IS_TI EST MP ) ' /* 0; 29 */ ttdefine HERE_IS_PUMP_MAP ' *' /* O; 2a */ ttdefir.e RELEASE_CARD_PLEASE +' /* 0>!2b */ ttdefine ND_3201 , ' /* 0 2c */ ttdefine 3201 ON ' -' /* * 0!2d */

ttdefine CHANSE_PRICE_PLEASE /*- These are identical to LTS except ttdefin GIVE_ME_PUMP_TOTALS /* that they start with STX * ttdefine HALT PUMP PLEASE

Requests Emitted by Touchcom

GIVE_ME_TIMEST MP GIVE_ME_PUr1P_MAP I_NEEi_>_AπENTIDM HERE_IS_A_TRANSACTION I HAVE A HOT CARD

Requests Accepted by Touchcom

tv-.-i- -n÷ Dil

-2.- ^ - r A. E_PUMP_FROM_ME / * ι mp 1 em en ted * / RESET_YOURSELF_PLEASE /* implemented */ HERE_ I S_T I MEST MP /* imp, on demand, not broadcast yet * HERE_ I S_PUMP_ P /* imp -*/ RELEASE CARD PLEASE

" I ouchco wi 31 rcsend _. Mr.I- . ed iiι _rs£.ge up to 7 rimes befnre declaring the j _ n. dead ψro ded the MAI is a j _ r.. -type? NAl , bad bcc eg.)- Touchcom will resend an unanswered message up to 3 times on a 2 second timeout before declaring the lin. dead

Pump Control Modes

There ai- e three modes.. Normally, the Touchcom uni should spend most of its time i TOUCHCOM mode; ιe. , taking in dough and pumpin gas. Bulloch will see r.u LTΞ pump control messagee when the rouchc unit is in Touchcom mode.

If the customer wishes to pay with a type of credit card we cannot s'j pπrI- „ wr- ι-'i 33 ^i] rh . EC-SI mode. In t i- mode we t-_:_i. the customer to "Proceed to fill and pay at . IDS. ". We wi J 1 assert pi

* 'C' , and send LTS events (OFF HOOI /ON HOO. ) as the f happen. We wil _. rela-y your LTS commands to the pump and vice versa. We wil perform no mediation, translation, error checling services, timings.

Uii.- ι r ι t t I p un . I 1 <u l s^er i -i ^- < * -. 11 _ l r- r— r~. ' rit r t_ - I t I fc J .

We provide a third mode, the BULLOCH mode. This is initiated Bulloch sending a GIVE_ME_PUMP request to Touchcom. In this mod the Touchcom unit relinquishes control of the pump as it does KIOSK mode. This mode is provided so that Bulloch can chan prices, allocation limits, get shift reports, etc. without causi confusion in the Touchcom software.

It. might also bs useo _. ; (bed torb_. i'* some ot he I ouch.c m 1 devices are broken and the station wishes to continue pumping.

GIVE ME TIMESTAMP

opcode ' . ' (0.-.21)

Touchcom is requesting that Bulloch send a HERE_IS_TI ESTAMP messa

GIVE ME PUMP MAP

opcode ' " ' (0x22)

Touchcom is requesting that Bulloch send a HERE_IS_PUMP_MAP rnessag.

I NEED ATTENTION

opcode '#' (0x23)

. o ohe L.f u_i - a er

Touchcom is requesting that Bulloch present the message to t human, and eventually send a RESET_YOURSELF_PLEASE message.

The Touchcom unit will remain blocked until the RESET_YOURSELF_PLE message is received.

The message is contained in a 20 character data field between the r i t j ci and tl"ι ' DEL. 7lit? me_?sa-.ιe is sent "J II th lesr".

HERE IS A TRANSACTION

It's an LTS message consisting of the response to an LTS 'D' comma starting with an STX and a sequence byte between A and Ξ (inclusiv

' opcode '-?' (0..24)

Touchcom has completed a transaction arid is posting Bulloch t-h th filling data and refund data. No repl message is e.tpected b ,. Touchcom. The data are contained in a field between the ID field and the DEL. This field consists of a 6 character right justified zero tilled cents amount followed immediately by the raw LTS ill. g dat .

The refund data are provided ≡o that the human will not be sur r se when the customer wall's in with a credit slip.

I HAVE A HOT CARD

opcode "/. ' (0κ25)

POS processing has determined that the card currently in the car reader is HOT. The Touchcom unit will retain the card until th Bulloch system sends a RELEASE_CARD_PLEASE request.

GIVE ME PUMP

opcode '*.' C0x26)

Bulloch is requesting control of the pump from Touchcom. Th request willbe honoured if a transaction is not in progress. I the request cannotbe satisfied, the 0κ20 bit in the first stat byte of the NAK will be set. This means I_AM_BUSY.

THIS IS A MODE CHANGE REQUEST. If the request is AC ked , Touchco originated transactions can no longer be made.

TAKE PUMP FROM ME

Bulloch is requesting that Touchcom take over control of the pump, THIS IS A MODE CHANGE REQUEST.

RESET YOURSELF PLEASE

opcode ' ( ' (0x28)

Bulloch is requesting that Touchcom go into "transaction" state fr "error" state.

HERE IS TlMESTAMP

opcode ' ) ' (0x29)

Bulloch is requesting that Touchcom use the supplied ti estamp f all further transactions. The ti estamp is in YYMMDDHHMM for and the field lies between the ID field and the DEL. HHMM is hour.

HERE IS PUMP MAP

opcode '*' (O 2a)

Bulloch s requesting that Touchcom use the supplied map in order determine which hose is associated i h which grade on the specifi pump.

The map is supplied m a 3 character data field between the ID fiel and the DEL. The grade number associated with a physical hose i supplied at the relative byte number of the hose in the fiel This is a complicated way of sa * . ng the map WLIJ e_ thor be- "123"

RELEASE CARD PLEASE

opcode '+' (0> * 2b)

Bulloch is requesting that Toαchcom eject the credit <zs:rc} currentl held in the card reader. This request follows a Touchco I_HA E_A_HOT_CARD message, after the customer has been shot, stoned exiled, or whatever.

POS

Touchcom will generate Petro Canada 222 and 10O messages for credi card authoris tion and transaction settlement. Bulloch will fil in all fields which Touchcom does not have access to — Touchco will field such fields with blank characters (0κ20) .

Touchcom will not timeout on these requests.

#include "/user/steve/dave/dave_request.h"

-Sde ine SEND_IT 1

#define GIVE_HI _THE_PUMP 2 ttdefine REFUSE BiM THE PUMP 3

ttde ine OPEN ttdefine ENABLE_BULLOCH_MODE ttdefine ENABLE TOUCHCOM MODE

-2Sb- bul loch/ρuιTιp_e.τιul . c ttinclude "vars.h" ttinclude "const.h"

ttdefine HOOK_OFF_STATUS * U' ttdefine AUTHORI2ED_STATUS 'W ttdefine DISPLAY_3TATUS 'D' ttUtfT 1 i it c-_- -_-r.__L.-L_:- jr l_fcι t fr.__o f t-f i U ! ttdefine PUr-iPIMG_STATUS 'C ttdefine HOOK_DOWN_WITH_SALE 'B'

static char illing_dataC 100 3,

_pac..etE. 200 D, _ is_ u , _hi s_sequeπce , status;

Sta ii- Uι >s_I yPιt;d _hθSt_._nUιiibt_;r j

_pumρ_number |t

Hook down event < )

t fc-y 1 =- __?r ι_har *ι_ — _ρa__kt_ , t|i

zero ( _pac..et, sizeof ( _ρacket ) .5

*c++ = END;

*ctt -= _his_sequεnce;

*c++ = * Pump_number < ) ? T0CHAR(Pump_number < > ) Ϊ _his_pump;

*ct+ = TuuHHKlHose numbe . . ) ~

κ-c++ = HOOK_DOWN_WITH_SALE;

*c++ -= BASE_STATUS;

*c++ = DEL;

..C++ = calculate_bcc ( _packet, 7 ) put . _ρacl-.et, 3, builoch_out )

Set_hose_used ( h ) unsigned h3 r

hose number = h;

Hose number . .

char Hi s_ eq eneel )

return _h_ s_ equencer,

Set_ ump_number ( p ) unsigned p;

uiiifi n ii'L ' er

- -^-

Set_his_sequence( asequence ) char asequence; -C

_his_sequence = asequence;

Decode_hi s_pLiιTιp_aπd_seqLience ( message • char -*message; r

_his_sequence = message!. 1 3 ; _his_pump = messageC 2 1 ;

Pump_n.Ltmber < )

return _pLimρ_nL Tιber ;

Set_status_pumpi ng ( )

-. at us = PUMP INB STATUS;

Set_pump_hook_o ( )

_status = HOO _DFF_STATUS;

Se t_ρu.τιp_sal e_ρendi ng

status = DISPLAY STATUS;

Set_sale_comp3 ete ( )

status = S..L.E LUMPLLrC fc.TAlU.

Set_pu.τ.p_f i 11 ιng_da a < s ). chsr *s; r

COPY_SAFELY( fi 11 ιng_data, s );

,e l ■ u _pol L

Repl y_to_ρol 1 c _status

Rep I y_to_ρol I f . stat.... , data ' c -.r statL.-», f-datd;

_ r

register char -v-c = _ρac et; unsigned length;

zero. _pac.:et„ sizeof ( _paci et ) ) _\ •*_. .- - AC! .

.u i -i- hi * -

*c++ — Pump_numbe < ) ? TOCHAR(Pump_number ( ) ) : _his_pump; *c++ = TOCHAR (Hose_nLimber ( ) ) ; *c++ **** status; *c++ = BASE_STATUS; while < *data )

* c •+--;- — * ata+÷- *c++ = DEL; length = c — _packet;

*_++ = calculate_bcc ( _packet, length ); fput ( _packet, length + 1, bulloch_out );

Reply_to_filling_data ( ). r

Reply_to_poll DISPLAY_ΞTATUS, fi 11ing_data >

-_

Reply__to_authorize ( )

Reply_to_poll ( AUTHORIZED_STATUS, " " ) 5

Se:__si:a u=__pumping < ) s

__

Reply_t.o_5al e_cofnplete C ) r

Set__5ale_complete< ) ; T.".Uϊ'o—- „ .11' .'.5_

Ac. no ledge_control_message< )

Reply_to_poll ( _status, "" );

n ■ i r P ! ~ 1 ι_ L lilt

register char -*c = _pac. etrι

ZE * ΓO( _packet, sizeof ( _pac. et ) );

*c++ = ACk;

*c++ = _hιs_sequence;

*c++ = Pump_number ( ) " TOCHAR .Pum _r.umber ( ) ) : _hιs_pump;

-*ct+ = ' 0 ' ;

K-r-r-t- = \ ' •

*c++ = DEL;

-.C++ = calculate_bcc ( _pac. et, 7 > f put ,_pε-.c. et , 3, bul loch_out 1 ;

M<m _μacl et < ~ z> at us 1 , status? 1 char tatusl . status2;

_ register char *-c =• _pac. et:

:eroι _pac. et, sizeof ( _ c. et ) )

• r J = * I ii ≤ c -eqι H l i'- |

*c++ = Pump_number < ) ? TOCHAR (Pump_number ( ) ) ϊ _his_pump;

*c++ = status!;

*c++ = status2;

*c++ = DEL;

* c + - = calculate_bcc C _ρacket, 7 ); f pu '._packet , 3, bul 1 och_c>L.t > :

li I l I 1 Of.11 /-_>-' r , J . t- _ ■ I " < v 6' ■ C ttinclude "vars.h" ttinclude "const. h"

servιce_dave < r ) request * w

G-<ι -i _μ-ιiιr..r. i I'-'ii'ihe ' ι "■ -_. _.' > " switch ( r— opcode > r _ case OPEN: _oρen i r- client ) ; brea. ; case 1_MEED_ATTENT10N: _attentιon( r > ; brea. ; case GI E_r-1E_PUI v IP_r-1AP: _pu.τ.p_map ( ); break; case GlVEJ E_TIl"JES. AMP: _timestamp ( ); brea. ; case MEP.E_IS_r-ι_TRANSFιCTlUN__t!-arι ar_tι r.t r > ? ln-eΛl ; case l_HAVL_A_HO " ._CARD: _i * iot_zard < i; brea. ; u Ξtf r iucir _Hl ι | rlUhi- H I l uι . ! I 11.- 1 _ dw uln ' , !j i t_'ι_ιι , case . IDS, _PAYΪ1ENTs _.. l os! _pay,τ.ent ( r ) ; brea. ; c ase CLE R_PR I CE_CH NGF_PEN01 NG _

_cJ eur_prict__rhar.ge_per.d- ng . ) ; br eat ;

Cc" =?-.- ι_Uf l.' I I H u! ii ' Jπ - ' -t-J =s . I ' _ LJ, 1 - iii! ',

hot card ( )

_attention< r ) request *r;

Queue_request ( I__NEED_ATTENTION, r->string_data );

Queue_request ( GIVE_ME_PUMP_MAP,

static unsigned _poll_couπter = 9;

_ti estamp ( ) r

_ρol1_countert+; i -f . _pol l _couπter >= 10 )

QLieue request ( ME T I. MEST AMP

Post_l ocal _ti n.e ) ;

.transaction ( r ) request *r ;

__.__-L_ ιos_-'__used ( r- value " . > ;

Queue request < HERE_IS_A_TRANSACTION, r-- str ιng_data ) ;

Dueue_reqLiest ( opcode, data ) char opcode, -^datas r

i - '."ji ιQ ~ _ _ρ .. id A r . J — opcode; retr y_counter = lϋ;

CQPY_SAFEL < outbound_data , data >

,..ι os. __τιuthoπz tιon ( )

=el._ho = ≤'_used . L ' i; Set_pLuτ.p _hoo! _o-f f ( ) ;

. L-,' .t- .Li .^ .1 t-M-i ,-.'_.i_-._ _„. * ι h ,.' i r ι~- __ , I— 11 U ,Mri_r_' _ 'r ~_ r-' ! l~l,ri -ι ιr_ - . ' _ .

_ _■ ιo=l _ a ιτ.er.L ι r < rogue?. -*-r " _

>I>^t__ho≡ ~ '_ u__t~-d ' r- value " .. . ;

Set_pumρ_f l 11 ιng_data ( r- strmg_data )

Oueue_request < TA. E_PUMP_FROM_ME, "" );

*/

.open ( user id )

Ltnsigned userid;

my_client = userid: opened = 1 ; request_ρeπdιπcj = ϋ;

lσad_tc-tals . r ) request *r;

do

load_hose_total ( r— >value REPLY C caller . ) , r > ; RECEIVE ( caller . ) , r ); while ( r— >value3 i = 0 ); hos.e_total_ρending = 1;

bul 1 och /sysi: em_ t_ me. c

#ιnclude 'Vars.h"

static unsigned year, month , day, hour . rn l n sec;

Uρdate_local_tιme ( t_ me_message ) char -*tιme_message; r

tsscanf < time_messaqe + 5, "7.02d"_02dV02d7.02d7.02d7.02d" , tyea , Smont , ./d y, f-hoαr „ S-min, f.sec ) ;

_ict s s em 11 iTi. ( . Yea ,, month , da> _, hour , min, sec ' .

Post_ local _tι e ( ) r

unsigned -*q ** t_qn ... ime- ( .5 cl'11-.r butter * I. _ '- J ;

Decode_system_tι me . get_qns._tι me ( > >

t spr i n -f < bu-f f er , " T7.02d7.02d7.02d7.02d7.02d7.02d " , year, month, day, hour, min, sec

) :

control_event ( my_client, buf-fer );

Decode_system_timeC date > unsigned *date; r

unsigned am_pm

day = (dateC 0 3>>1) ?. 0x3f; month = (dateC 3>>S) S. Ox-f; year = dateC 0 3 >> 12; year += 80; hour = d teC 1 1 / 3600; min = CdateE 1 1 7. 3600) / 60; sec **** dateC 1 1 7. 60; aιTf_ρm * = date C 0 2 §. 0x 1 ; i -F < am_pm ) hour += 12;

unsigned y, in, d, h, mn, s;

unsigned *ma e_qnx_ti e ( );

set_date( make_qn.;_time ( y, m, d, h, mn , s ) );

- .IF -

static unsigned _date C 2 3;

unsigned *make_qnx_time < y, m, d, h, mn , s ) \ r

unsigned pm **** 0;

■■ -= 30; i C h >= 12 )

pm = i; h -= 12:

ε t= h * 3600 t mn * 60;

zero! _date, si__eα-f< _date ) )

dateC 1 3 =

return date;

unsigned *get_qnx_ti e< ) r _ get_date( _date ); return dato;

bul loch/timer_f ired. c

#include "vars.h" ttinclude "excepts.h" ttinclude "const. h"

-r* _: . / i 1 ιι_t=.r __v 1 Y t=; -\ /

_- int c;

Clear_my_timer ( ) ; switch ( c * = Next char ( ) ) r

case TIMEOUT: Bend_queued_request ( ); break; case STX: Acceρt_control_messag ( ) ; break; case ENQ; Emulate_ρumρ ( ); break; case ACK: case NAK: Acceρt_l ink_resρonse ( c ); break;

-.

Set ιτιv timer . HALF SECOND ) ;

Bend_queLted_reqLtest

if Crequest_ρending)

send_request_to_bulloch ( request_pendi ng ) ; reαu-iit ' e α 11 e s t □ e π diπα; r fc- Ut (..'. t. S ■_ D ir-' 1 ϊ f.l 1 I I Q

—3 \-

if .bose_total_pendιng .= 6)

send_hose_total ( ho<=e_ total_ρer.dinq ) tor _ι_ __pεndrr,Li*t +;

A ceρt_controL_message ( r

Pushchar ( STX ) ; if ( Inbound received < inbound ) )

-.eset inbound ( ) ;

Pushcha c c ) ; if ( Lnbound_receιved ( inbound ) ) r

Lt ( st_rBqup * -t == PIVF ME_ PUMP. MAP .

1 i i \ ' I " ' -ι I '.it." . ; ' " i ". ' " !

Update_lαcal_time ( inbound ); Reset inbound ( );

r'r uc !__ __,--- _ -!_.r. i- i-il __.!.>__ __ say •__ . .

3et_hi s__sequence ( inbound C I 1 ) ; switc ( i nbound C 4 3 )

, vr

case TA E_PUMP_FROM_ME: break; case RESET_YOURSELF_PLEASEs bul loch_event C ir.y_client, "RESET" > ; break: case CHANGE_PRICES_PLEASE_ Process_pric5__change ( ); e u n; break; case GIVE_CASH_TOTALS_ ι___-_.i-_ ■D-_Tlivι__-r._L_-rr-..r_-_.T__-. TJ.-i -r1-»ι-—_.i-i r ' --iLι. •—_>• _-

-_._-.=.__' r-t_.i_-_._-.<_.__._L.ι-.r._J_—>_ ___-..:_.tL_ 11 ._; __ ._ r _-'.___ ' -:-_-►-' . .' ,

Acknowledqe control messaQe( ) r;

EιTiUl at _pu * rιp < )

' >..i _s T I •_ i i c. r * r.:.. > '• ■. L-. ;

^ -503 * -

l-f ( Inbound_rece ved ( inbound )) C

Decode_hι s_purrιp_and_sequence < inbound ); swιtch< inboLindC 4 1 ) r _

-.3---. - " --|ΛTU5. Re l •-.1 o < * . talus , pnl i . > ; h.-o,-,! ; ά'._ 0 ! __■£ LH _ i. ' i-i . {■_ i KepJ . .. tϋ_ τ i. J J n _ (.ι -.-i i..-. . , b .nl ; case AUTHORIZE. Re l y_to_au thori :e ( );

PosL_authαrι_-atιorι ( > ; brea. ; case i 0T0R3_QFF- Post_hal t . > brea. ; case r0T0R3_0N_ Post_restart ( ); breal ; case SET_SALE_COMPLETE. Repl y_to_sal e_co.τ.pl ete < );

Post payment made ( r, brea. ;

t -i bound ( )

- 0 --

bulloch/vars. h

#iπclude <stdio.h> #include <setjmp. h> ttinclude "bulloch. h"

tti det GBLGEN

#detine VARIABLE

-B-else

#detine. VARIABLE extern

#endi-

VARIABLE unsigned opened, hose_total_peπding , debug , request_ρeπdin , last_reques , retry_counter , .τ.y_port, .τ.y_elieπt;

*b * ulIoch_outp

VARIABLE char inbound L 200 1; VARIABLE char outbound_data C 200 3;

VARIABLE j.τ.p_bu-f ini ial_tra ;

bulloch/int/bul1 i_int. c /* stub for pump task only */

ttinclude "--bulloch,h"

extern request dr;

1 oad_ρuιιιp_ ' t a L . t_v__ι . nuriii ' . t.- ' J •"• L _ Hst'i. f-_.ii ,., ■ ,•-• unsigned task, pump; char *total_data;

Linsigned total „no;

dr. opcode = LDAD_TOTALS; dr. val ue = 0; > dr. client •= 0; d r . v a 1 u e 2 = p u rr, p 5 dr.value3 - totd I ._nos

COPY_SAFELV. d . tri ng_data , total _data . : SEND( task, &dr ) ~

*

— 3θ -

bulloch/int/bull_int. c

/* dave's inter-face to the BULLOCH POS */

#include "' " -bulloch,h" ttinclude <magic.h>

extern request dr; static Linsigned bulloch,

i_need_attentioπ . pump, message ) unsigned pump; char -*message; r τ. bull_cι * nd( I_NEED_ATTEMTION, message, pump, 0 );

pri ce_change_corr.pl eted ( pump ) un igned p ump ;

buil_c.τ.d . CLEAR_PRICE_CHANGE_PENDING, "", pump, 0 >

-.

give_ιτιe_ρu.τιp_map ( pump ) unsigned pump;

bull cmdC GIVE ME PUMP MAP pump , 0 )

give_me_ti estamp ( pump ) unsigned pump; r

bull_cmd . GIVE_ME_TIMESTAMP, "", pump, 0 );

[_» * « 'in rii ' ,_._. i ,, no^e η data > unsigned pump, hose; char *data;

bull_cmd . LIOS...PAYMENT, data, pump, hose );

I los. _author ι;ei pump ) r

bull_cmd . . 1051.AUTHORIZATION, "", pump, 0 >

tere . is_aι_tr<=.nsactιon . pump , hose, data > unsigned pump, hose; char s ala;

bull_cmd( HERE_IS_A_TRANSACTION, data, pump, hose >

ι_have_ά_ ho r___e_-.ru < μump > ιιn__ i i ifc."l i iήip

-3θS-

bull.cmdC IJ-.AVE_A_HOT.CARD, "" , pump, 0 );

open.bulloch ( dave, port > unsigned dave, port;

bullochs_ρort = port; bul-l_c-T.dC OPEN, " " , 0, 0 );

bullochs id( )

return detach ( bullochs.port );

bull_c d( opcode, string, pump, hose ) unsigned opcode; char *string; unsigned pump, hose;

i (bulloch -= 0) bLilloch = detach . bul lochs.port ) dr.opcode = opcode; dr. client = event.queue.id ( ); dr.valueS — pump; dr.value3 = hose;

COF'Y.SAFELY ( dr. striπg.data, string ) ;

SENDC bulloch, S.dr ) ; j

bul1och/i t/cfi1es bul1 l.int.c bull int.c

bul1och/int/make-f-ile

CFLAGS = -S +Wc,+u SOURCES **** ©c-Files, OBJECTS = ©objects

'"- -directory: Φ (OBJECTS) type all done

bulloch/int/objects

bul11 int.o bull int.o

cnt/2260.c

#include "vars.h" #i ncl Lide < t i me . h > #include <set mp.h>

cnar _..__- 1 ec r - 4- J — '_ EDI , " ' . » ; ._' ' \0 ' J- 5 .ri__.i- }jUI .lt.l * t J — - -'. t- l I i, , , _ '•.'•-' -• I

FILE -s-iπput;

FILE ^-ou put; j.T.p.but i nit i al .trap;

main (argc, argv) int argc; char -ft-argvC ' J; r

request r; unsigned task, code j

initial.error (code) ;

initialise (argvClD, argvE2_i , argvC31) ;

ar ( ; ; )

j. _ .. -.. — r~.r-,— .i — τι it — ,-,.•. v.. .- o ._ . _

* -f i, (tasl 3) -= C T_PQRT > timer.-f ired ( ) ; else process.request <S.r); REPLY(task, ?.r);

initialise (device . name, addressl , address!' ) char *device . name, *address_ , *address2;

log_2260 ("start"); Cnts C 0 1.opened = O; Cnts C 1 3. opened = 0;

Cnts T 0 . live = 0; nts C 1 1. alive = 0;

strncpy (Cnts C 0 1. address, addressl, 2) _ strncpy (Cnts C 1 3. address, address2, 2); if . attach (CNT.PORT) ' =- O )

1 on--l_.fr.p ' 3 niti al .fi-ap . i .._ " J'-IF, '^

u l ≤=. J 1 Ol" ( 'l !| input = my.open (device.name, "r. " , initial trap,

NO.DEVICE) ; output = my.open (device.name, " vu", ini ti al .. trap ,

NO.DEVICE) 5 f i ..-"It 3 nrJi- 1 ' " '• ι pi 11 ) r

*_«u UOU v. f tcu 5

set_ti er (TIMER.SIBNAL, RELATIVE, SERVICE.INTERVAL,

CNT.PORT) ;

initial error (code)

..msiσn ε

car *messaqe;

switch (code)

case NQ.TIMER-- message = "no timer port"; break; case NO DEVICE: rnessaqe = "no device"; break;

. _->_i __._____• _' l..l____.__._rtClt_ r )

1)

; i ιιifc_r 1 r t__d ( .

11 •_ i ;

for ( i = 0; i < NCNTS; i++! select.cπt (Cnts + i ) ; tor ( i = 0; i < NCNTS; i++ ) poll.cπt (Cnts + i); rijr . _ - » S- J. * - Γ-IU. i 05 1 -r-l

checI .timer (Cnts t i > set.ti er (TIMER.SIGNAL, RELATIVE, SERVICE.INTERVAL, 0,

CNT PORT) ;

poil.cnt (c)

char -*msg = c — response t 1; unsigned dave — c --user;

i-f ( poll (c, c ---response, sizeof (c - response)) ) r

i-f ( *msg == BEEP ! ! c -.-•opened == 0 ) return; c - timeout - o; c - ti er.r unning - 0; switch ( *msg ) r

case STAC. _ stec. _ event (davo, msg ) ; tree.. ;

C ' --.t NOTE. noLe.even .d-?vt_,, rnsςi i ; tareai ; e se.. LJE T. case CARD- card .. event (davo, msg)-, bre_*. ; case PRINT, pπnt.event (dave, sg ) ; brea. ; de-fault: cnt.event (dave, msg); brea. ;

- I-V-

select cnt (c) cnt *cι

if ( c — .--opened == 0 )

Cl ~ " . * * T 5 ti.' t ϊ. j O te.' . l 1 ' ϊ Cj -* c —>beep_ρending = .select (c, E'EEP.PLEASE) ; else if ( c —>request_pending ** == O )

;lse c —>request.ρending = .select (c, c —>co.τ.ιτ.and)

ι_. ιt_ι_h linrrr

if ( c — >oρened ■_.. c — >timer_runπing ) (ι_.

__.v".11 u h

ι_c.ϊ_-t_- STACK: stack.event (c -user, "ZZ"); break; case NOTE: note.event (c •• user, "ZZ"); break; case EJECT: c s CA _ card . εvent (c r i >-' L Ever.'. r k;

de-fault: cnt. event (c - user, "ZZ"); brea. ;

•.

c - -timer.runnmg = 0; c -✓timeout = 0;

set.cnt.timer i , seconds' cnt -K-C; unsigned seconds; r

Ltnsigned date [ 2 3;

i-f ( seconds -= * = 0 )

c - ti mer.rL-nning - u: return;

g t; ι_ _ U ci I _-' \ u _.( L t_ . , c - timeout = date I ] t seconds-- if ( c - t.fiieout SC QHDS.PER.HALΓ.DAN • r c - -ti eout - ***■ SECONDS.PER_HALF_DAY- /-* wrap it */ c --am_pm = 'date C 0 1 1 ϋ:: 1 ;

_-- .fe-

c ->am_pm = date C 0 3 .. Oxl c — >timer_running = 1;

ti er.elapsed (c) cnt *c;

uιιsiyπ__O __att_ __ 3;

get . date (date) ; return (c — >timeout <= date C 1 3 ) §_& (c — >am_ρm ——

(date O 3 & Oxl ) ;

poll ( c , bLit-f er , but 1 en ) char *b Litter;

Linsi qned but 1 en ;

fc_l_\__X Vi__

memcpy (poller -t- 1, c —>address, 2);

*bu- fer = '\0'; striπg.out (poller);

r u case TIMEOUT: log.cnt.-f ai 1 Lire < c,

"not answering poll" ); break; case EOT: c - alive = 1;

*c

/-* CNT has nothing to s_.. *

Cl Q=>'- Ci'i . _τ .3 l 1 _l|-ι-_ '' _ " _ > _ brea. ; case STX: received = recei ^e.message (butter, bul len) 5 c —.-all ve - 1 ; clear_cnt.*f ai lure ( c ); break; de-fault: break; /* ignore jun.. */

return received;

static int cnt has -failed:

log_cnt_-f_.1lure ( c, m )

char logπ.ll 40 3;

if ( cnt has failed == ( c- -opened )

i n t : . I ijC1111 , :>'"|. |r_ >"

1og_22<_.0 ( logm 5 ; cnt has failed = 1;

clear cnt failures c ) cnt *CΪ

char log .. 40 3;

if ( c— >oρened 2... cr.t_has.fai led * = * = 1 ) r

tsprintf ( logm, "%.2s 7.s" , c->address, "link restored" ); log.2260( logm );

ι_..'_ iiciS Tt-.l_.t_u — u;

select (c. cmd) cnt. *c: fiδr *UlllOΪ

int

memcpy( selector t l, c->addresε, 2 ); string_out( selector ); switch ( nextchar( ) )

- \ -

case π CL ret - senri. essage ( cmd ) ; if ( ret ) clear.cnt.f ai lure ( c ); break; case TIMEOUT 1 og.cnt. ai lure ( c,

"not answering select" > re . ; d e -i -? u 1 t : brea. ;

retLirn ret;

send. message (message) char *message;

ini = NUMBER DF RET IFS. bcc — calcLil te be ;sage )

for (

string_out . me•_.sage) ; char_out (ETX ) ~ char.out (bcc) ; if ( ac. nowledged ( ) ) return 1;

. tLI r. "

calculate.bcc (m) char *m; r

int bcc = 0;

'•-. h 11 e '. -•*-" " ! ) bcc - ' -= ETX;

return be v-5

acknowl edged ()

switch ir .ar

LS5I_ ACK: char.oLit ( EOT ) ; retLirn 1 ; break ?

return 0; break;

- ^1-

char -x-buffer; unsigned buflen; r u int i , t; unsigned ;: ;

__har *-b s

pushchar (STX) ; for ( l = 0; i < NUrΥBER_OF_RETR I ES; i ++ ) r

x = 0; b = buffer; t = TIMEOUT; while ( (t=ne:-tchar ( ) ) ! = STλ )

. ' > * - wai t for oeginnmy of message ->-•' if ( t==TIME0UT ) return 0;

/* it never came, so give up */

computed . bcc = 0; while ( t != ETX )

* if ( (t **** nβittchar ' ( ) ) ==- TIMEOUT)

/* characters stopped coming */ return 0; * so gi ve up */ computed_bcc " = t; Lt ( I =- * -- ET ' ) : . I.tτ ' : ■•: I • " « :

-3.2.Z-

if ( (t = nextcharO)—TIMEOUT ) return 0; if ( t * == * computed.bcc )

.t r .1 i-li i L-'-

___.se char out (NAK)

else if ( ++x < buflen ) jj-btt = t; '* st_j. •__ ιι.t_55ayt'

.sage too big q-__'c_ ouι_; * so give u

out; return O :

εign.off ( )

char .out (ACK) .

-3 -

int char stack = —li

pushchar (c)

nex char ()

if ( char.stac. = 0 ) /* try stac. first */

*. t = char__st i ι 5 char__st&cl- — -1 ;

->

else / trv corn line r v. x i ! a-l i I " _w . " ι t I l .'-J . L fiμU ' ) set.i. mer fTJMEP.HAl EUP , RELATIVE, il. II-IPACTE. F _T L ME OL! r , 1

if ( char.waiting (input) ) r

t — getc ( l put ) ;

-31- -

else t = TIMEOUT;

return ts

char *s:

f ut (s, strlen (s), output);

char

tput * .&c, 1, output) f t

-32.5 -

cnt/2260.map

.Segment: 1 OOOO to 1427 (5160 bytes)

.Segment: OOOO to 01BE (447 bytes)

.Seqment:3 01BF to 0515 (S55 bytes)

.Total size is 193E (ό4ό?) bytes Col • ) ' " ι5. prologue C 1 05E opl1ogue CO1 0067 st..overf1ow COl 00S3 -Ϊ icbeg COl 0084 -main 5 COl 0114 initialize ' - COl. 1E0 initial.error CO1 0225 11mer_fJ.red COi 02C4 poli.cnt- C01 03S5 select_cnt COl 03F4 chec'..timer CO- 04B2 set.cnt.timer CO 05 L-1 t_.mer_ oI aμ ed C I G S.J poll COl 062E 1og.cnt_. " a. lure COl 0672 clear.cnt.f ilure COl 06B7 select COl 0732 send_message C 1 0 "~ -'... r <-ιI cuLr_>1"-. 1 o C■I :I ii'ji'J ocJq&■

LUi

COl 09BA .process. equest: CO1 OA1C _beep_cnt> COl 0 31 .c1ear_timer> Ol 0A46 .queue.request> COl 0A9D . isal i ve> Ol OACD [open> COl OBOC .val id.cnt > Ol 0B4B ~ .csι.r d .even t > COl 0B65 ' . cnt .event > coi 0B7F [no e_event >

COl 0B99 " . p r i n t .even t > Ol OBB3 : -st ac k.event > CO1 OBE4 .event > CO1 OC2D. [ 1 r eqLiest 1 COl 0CS5 .disal low> COl 0CA4 .my_open> COl 0CD7 .sleep > COl OD1D . ab s_sl eep O.1 OD4. . set _ ....1 sT.er . " •- Ol ODAV '-■ i " ι~.' " . i.. ι ■/ -

- 1-

CO 1 :l. S" !" " . cV _-

— 23-

strcmp

<strcpy> strlen >

<send>

< abort >

• " . LI π b r sal a b i -■_•

< long_-i rι > <nargs>

<vc.send_re 1y> < c.cre te>

<vc.create2>

<k r_vc.destroy. -..dεf servs

'■ ' ..set_acc tlags

<se .exce ion> -.escape.tty

COl 1322 <unhold>

..Ol : -. ci.nt. iicε.

CO! 132E COl 1334 <force.ready> COl 133A <set_ρriority <set user>

; " I. i I

-32 -

DOO OOOC E. * c_pendιng

DOO 0010 Euc.-fp -

DOO 001 -Eϊrc.pc -

DOO 0 14 E;cc_perrr.it Ϊ

DOO 00IS E ** __t status DO.

DOO 0O2O Brea..count

DOO 0021 My.tty-

DOO 0022 stac..base

DOO 0024 - Cmd.-fl gs-

DOO 0025 My_pr1or11

DOO 0026 stdiπ

DOo 002E stdout

DOO 002A 'stderr

DOO 002C Free.l1st

DOυ 002E End_ot_tree

DOO 0032 .Argc

DOO 0034 .Argv

DOO 0034 st1.11m1

DOO 0036 SAVE

DOO 003S TEMP

DOO 0060 Co e . -flaq * -

D'JG ' D i L-_er IT .>I

' '.' I O0___. i f"| t> .IL.'""

^ll'

2260.c globals.c service dave.c

-332---

cnt/cnt. h

ttinclude "/user/steve/dave/dave_request.h"

ttdefine MAX_CNT_COMMAND_LENGTH 150

H-defiπe NCNTS 2

-ii-α i lrit.- ______ ι__. t.. ι ttdef me ALIVE 2 ttdefine BEEP.CNT 4 ttde-fine CLEAR.TIMER 5

ttdefine CNT.PORT 21

typedef struct Z unsigned user; unsigned opened; unsigned beep.pending; unsigned ali e;

Linsi ned t _ mer_runninq; unsigned timeout; unsigned am.pm; unsigned request.pending; char command l_ MAX_CNT_COMMAND_LENGTH _J; char response I MAX_CNT_ OMMAND .. LEMBTH 1 char uddress X. 1" " Is J cnt *

--Ξ. -4--

cnt /const .h

-1

0x02 /* 2260 ascii control codes Ox03

Ox04

O Oό

0 15

2 /# ticks == 100 millisec */

2 /* ticks -100 millisec */

43200

"B00050"

ttde ine NO TIMER initial ization exceptions « / ttdefine NO DEVICE

-ιy S-

cnt /gl bal s ttdefine GBLGEN ttinclude "vars.h"

cnt/makefi1e CFLAGS = -3 +Wc,+u SOURCES = ©cfiles OBJECTS = (^objects

. 2260: $ OBJECTS) linkobj c=2260 >:=objects m=2260.map l=/user/steve/dave sort 2260.map f=l,2 t-r copy 2260 /dave/2260

qlobals.o: vars.h

9 cnt/objects *

2260. o globals. o service dave.α

-33 b-

:πt / ssrvi ce αave , c ttinclude "vars.h"

static cnt_*C;

prαcess_request (r) request *r;

Vδi 1 D ι_l 1 ι_ val Lie 1 ) switch : -αρcode )

case ALIVE: isalive (); break; case OPEN: open (r ->client); break; case SEND . IT: queue.request (r) ; break; case CLEAR.TIMER: clear.ti er C ) bre ; ι —__-.ϊ-fc. r-.r— i — I—. r»iι _ _. ___ -. _ DCCΓ_ -N i : __rt_.p_ι_n i...' J break?

beep.cπt ()

clear timer ()

C —/timer ruπninq = O;

queue.request ( r) request *r; r V if ( C - opened 2.S. C - request.pending == 0 )

COPY IV.ΓLL ' T (Li- rn 1 ,.-„-,nrl. ' - --t,--, -,,-. j-. ^

L - qu^'s _ ώTidT.I'I I ~ L. set c t timer (C, r- value2> .

i sal l ()

≤nL (L - user, ii.l ;

open iL'seπd)

- -.'_ •" >_'i " " ' ~'- 1 i 1 i

C - upened - 1 ; C - request.pending = 0; - ti er.running - 0;

L - timeout = 0;

int i ; •C i—5

C = ( O < **** i S.8. i < NCNTS ) ? Cnts + i : NULL; return C != NULL;

cnt/varε. h

ttinclude "cnt.h" ttinclude "const. h" ttinclude <stdio.h>

tt i ' d &. t B .fc ' L. ii E. N tt define V A I B L E ttel se ttde ine VARIABLE - extern ttendif

VARIABLE cnt Cnts C NCNTS 1;

*

_3_ + 0-

cnt/int/cπt int.c

ttinclude " A cπt. "

static unsigned cnt.tasl.; extern request dr;

unsigned dave; r w cnt_api.cmd (dava, BEEP.CNT) ;

cnt.clear.timer (dave) Ltnsi-gr.ed dave;

,r

, j_ „ r * - _ι _. t C'"ι ' T T κ.-?t— -t— . \

CΪ r L_eAj. l _L_.HU sϋ Vtf - L-L.ir.t-.K_ i IΓIJ-Γ

cnt_c.τ.d (dave, message, ti eout) unsigned dave; char ^m s age5 r

C0PY_3AFELY(dr_ string_data, message) ; dr.value2_ = timeout; cnt_api.cmd (dave, SEMD.IT) ;

cnt r ώ1 i ;

- -I-

return detach (CNT PORT);

Opt_! * ι ( ave )

d j-' 1 J. c i d (dave, OPEN )

static cnt_apι_cmd .dave, opcode) uns- gned dave, opcode; C i -, ' . cnl.tasi == 0) cnt_tcisi- = detach (CMT..P0R7 > ;

r. opcode - opcode; dr. val ue 1 = dave; SEND (cnt.tasl. , Z/ύr ;

dc9/audict. c

#include "dc9.h" #include "vars.h" #include "disk.h"

* Enqli French */

L.J.--P a tare L 2 _l __.__:-_ i-ι-ι_ . 12904L, 22614L, 22904L 3 Cl ip gc.od . morning I 2 3 15L, r 10L, 52315L. 53004L Clip good_aftεr C 2 3 S20L, 1600L,- 52315L, 53004L 3- ; Clip good.evening L 2 3 171BL, 2427L, 53101L, 53804L > Clip pay.choice _. 2 3 2614L, 3027L, 53S25L, 54428L 3-; Clip card.choice I 2 3 5312L, 10200L, 61225L, 62300L >j Clip petrα.choice C 2 3 10310L, 10900L, 62325L, <__3126L ; Clip car .auth C 2 3 ll<__lέ.L, 1191BL, <__4205L, 64420L 5 Cl ip al I.cash.in L 2 3 422όL„ 470GL, βOOOΞL, 60508L 3- 4 Clip waπt.receipt L 2 3 -C 12S07L- 13220L, 65403L, 65904L 3-; Clip credit.receipt C 2 3 = -C 44000L, 44715L, 102325L, 103213L 3-; Clip replaee.πozzle L 2 3 = -C 43509L, 4382SL, 101907L, 102212L 3- 3

Clip remove_your_cardC 3 = 3121L T 113Ξ20L, 113121L, 113520L 3- Clip out_o .service 2 3 = -C

Clip kiosk.told [. 2 3 =- -- 51600L, 52214L, 10590ll_, 11072SL 3-;

Clip bad.note I 2 3 = C 40906L, 416G4L, 95319L, 100002L 3-;

Clip bad.card L 2 3 = C 41723L, 42914L, 100123L, 101310L 3-5

Clip till. arn C 2 3 ' = -C 31607L, 32126L, 85715L, 90306L 3- « ,

Cl ip n■-■_...__g_card i: :; ■■ • ;. Z--. Z _. __.. _ ::-' ~ ,4 :_. : .. . ■' . .:_ i iii., 9330--,-.. • =

Clip other card >:. !__ ..I - : ' 508C.- . „ r,I._.-_. ■. , J-/'- ' S ' -_.L. _< * £-t:'iO-! ' -.

/* user cancels */

- Clip cash_cancel C 2 3 = C 32314L, 33111L, 90507L, 91416L 3;

Clip card cancel C 2 3 = C 33300L, 34203L, 91615L, 92522L >

*

/-* £'/'?' eιτι Crincels */

Clip card_-?beπd C 2 3 = C 44812L, 45510L, lυ3.".17L, _ O'.OO L : s

/ >- . lost- cancels */

Clip 1- IDS. _halt E 2 3 = C 40326L, 40722L, 94809L, 95223L 3;

Clip s s_down I 2 3 = C 22620L, 23<_.14L, 30323L, 81504L 3;

/* "bad" card outcomes * /

Clip hc.l * _card C 2 3 = C 30914L, 14J.2L, 84-2 ~ .L_, 85508L 3 ;

Clxf. decl ιned_card 2 J = f 3_- υ__L, 7. 727L, S4;.υ__L„ 3 Θ10L _ *

/ 1*- devices */

Clip noteε_dowπ E 2 3 = C 23816L, 24416L, 81611L, 8230 L 3;

Clip cards.down C 2 3 **** C 24700L , 25225L, 324 7L, 8311ZL J ;

Clip pπnLer_dead C 2 3 - C 254U0L . " ' ( W6L, 3_.31iL, 840 ILL ' , uiJ p bc.Ll-ι._down i 2 3 -- T :.5c. L , -i ( -20._!., ?-I ■" >"/ZL , 9-16:.''!. " ,

/* your pump number */

Clip pLimp_nLimberl E 2 3 = C 14004L, 14316L, 70S25L- 71312L 3;

Clip pu,r.p_r,Limber2 C 2 3 ■= £ 14 22L, 14320L, 7142ΞL, 71918L ) ;

LI ij iι...μ .1-,'ιf.ιd-r-r " . 2 I " ' I 'l l ! ' - " "<>. i " ' " -. M " "..-.. li

...L_ ! i.-ι.-ι]_._ i ifi.P .- ' L 2 " 1 -- ( ! ' _.•'!I :! _ ' < -'J ϊ-l " . "" ' ) " I "" ' " '.J _' I

Clip pump_number5 E 2 3 = C 20016L, 20410L, 73315L, 73816L 3-;

Clip pump_πumber6 E 2 1 = C 20ώ00L, 2092SL, 74001L, 71488L 3-;

Clip purnp_number7 E 2 3 = -C 21202L, 21528L, 74615L, 75110L 3-;

Clip pum _number8 E 2 3 = -C 21710L, 22106L, 75225L, 75720L 3-;

Make_audic_shDW( prQgram ) iπt prDgram; r

Cli *c = NULL,

*pLirr.p_number ( ) , *say_hel l o ( ) ;

char *p ****■ new_command;

switch ( program )

"_. case A_PL.MP_MC.NEY: c = -fan-fare; break; case A_ANNOUNCEs c = sayjiellα. ); break; case A_PUMP_r-UMBER_ c = ρu.Tip_number ( )p break; case A_C-Ar*.L'_uHG1C _ __ — cs d_cπθice, breaks case A CAsH_IN_ ■ c — all_cash in; break-; case A_RECEIPT_NQ_CREDIT: c = * want_receipt; break; case A RECEIPT CREDIT DUE: c = credit receipt; break; case A_CASH_OR_CARD: c = pay_choice; break; case A_PETRO_CARD; c * = petro_choice; break; case A_OUT_OF_SERVICE_ c = σut_α-f_service;- break; case A_BAL>_NOTE ϊ c = b ad _ note ; ϋr e.ά, ; case A_KI03i< ALERTED ; c. — ki osk tol d ; b eak :

case A_BAD_CARD: c = bad_card; break; case A_PRINTER_DEAD: c = prιnter_dead; break;

* case A_FILL_START_TIMEOUT: c = f i 1 l_ arn; break; case A_CARD_REPLACEMENT: c **** no_mag_card; break; casr-e A. _30ME_CTl-IEF<_CARϋ. c -~ ~ re !- ,|

....- =■ ... . _ r.N 'LL. CASH. •" -" _\l * . .(_ ' case A_LAMCEL_CARDs C = card_caiιcel ; ι_> i --.cil ; case A_CARD_AUTH J 1T: c =• card_auth; brea. ; case A_HOT_CARD: c = hot_card; bref ; case A_DECLINED_CARD: c = decl i ned_card ; break; case A_CARD_ABEND: c = card_abend; break; case A_CASH_ABEND: c = cash_abend; break; case A_REF'LACE_MϋZZLEϊ c = rep 1 ac _--■ _ nor z L e ; u i ri! ;; case ι-ι_! 3 Q l _HALT_ c = . l os I __'n l t ; bi-e l ,; cast; _'._. ' . , TEh_DOWMϋ c = fev ___ o..rι ή case A_NOTES_DOWN: c = notes_down ; b r e ! ; case A_CARDS_DOWM: c = cardΞ_down * preal e __e A__?iϋTΗ_DQWN: C - both_dt*wr. ; b r e a I case ι". K! " HG'JL CARD. c * i C'IΓIO* ' *3 yuur card? I'Γ t' f

3 -f ( C

Set new show audio ( /* de-fault */

( c

r..-'..ι ■ \ I

Set_ne _show_audio ( language ? 2 : 1 ) ; c t= language; one_clip( c->start, c->stop, p, AUDIO_DRIGIN ) ;

return c '. — i MU ¬

C-

Clip *c;

i-f ( 0 <= hour c.ξ. hour < 12 ) / * * figure out time of day -*/ c * = good__rr.orning * ι else it ( 12 <= hour ϊ... hour < 17 ) c = gDQcl_a-fter; el55 c = good_eveniπg * i

return cs

Clip -κ-ρuιτιp_n Limb r < )

Clip -s-c:

switch ( Hi s_p imp _n Limb er C ) )

.•i.'iϋi . ri i ' ϊ ' ϊD fc. " '! ' 1

case 2: c - pump_rιurnber break; case 3: c = pumρ_πumber3; break5 case 4s c = pump_number4; break; case 5s c =-■ pump_number5r, break; ca.-s 6: c = * - pu.τ.p__nL'.ιrιberό; break;

. _!•-..' •' , '_ i-'!l|ϊlD _ I iLiil.l .i- ' i . ' . '-.' ; case? S: default. c = pun.p_nLin.berS; brea. 5

return c;

--* $-

dc9/c-f iles

audio. dc9.c globals.c one_c1ip. c

IL - !__ >>ιι__r piayer. c prime_for. c service_dave.c video. c

-3 < V-V

dc9/dc9.c ttinclude "dc9.h" #ir.clude "vars.h"

rnatri (arqc, argv)

unsiqnecl task code;

request r;

l -f (code = set jmp dm ti al_trap) ) ιnιtιal_error (code) ; el e l n L L i c-i i l z e k ar q , arg ) ϊ

f or . ; s .

Fi- F. iΛ!T_ i-- 1 "!- ' r..- ) i fca-ii f_) * ==• t_ rner__port '

el se service dave etas. , ?.r ) ;

J I l I ϊ I -l I j I I , I in * "I' '

— ~\>-3θ- int pc; char *parms[]; r

i-f (pc != 3) longjmp (iπitial_tra , USAGE) ;

1 cq_vi deo ( " start " ) j

" i fri r _ρ or t — a oi ... ' a s _ ϊ J .' % disal low ( ) ; ρlay * er_in = my_opeπ (par s C 2 1 , "rv" , i ni ti al _ trap .

ND_DEVI E ) ; ρlayer_θLit = my_open (parms C 2 1 , "wvu", initial _traρ ,

N0_DE ICE ) ;, tlush_inpLit (player_in) ;

it ( attach (ti er_ρort ) ) longjmp (ini i l_tra . Q_TIMER) ϊ

initialize_cl ips () ; log_video ("ready" ) ; check tor loaded disk () ;

11.1 ti al _error (code) unsigned code; r

char -^message;

swi t ch < od e '

r

case N0_TIMER_ message = "no timer"; brea. ; case .O_DEVICE. message = "no device"; break; case USAGE: usage <); break;

1og__ -id"o (message ) ;

! l

usaqe

ttprintt (.stderr, "dc9 tιmer_port devιce\π") ;

_ S . -

dc9/dc9.h ttinclude "/user/steve/dave/dave_request.h"

ttdefine PLAYER_STATUS 1 ftdefine PLAY_SHOW 2

#dε-Fiπe STQP__BHOtø 3

#de* ine OPEN 4

ftde- iπe VIDEO ϋ

Sde-fine AUDIO

ttdefine A_PUMP_MONEY ttdefine A_AN OUNCE ttde-fiπe A_PUMP_NUMBER

#define A_CARD_CHOICE ttdefine A_CASH_I ttdefine A_RECEIPT_NO_CREDIT ttdefine A_RECEIPT_CREDIT_DUE ttdefine A_CASH_OR_CARD ttdef i ne A_PETRO_CARD ttdef i ne A_OUT_QF_SERV I CE 11 ttdefine A_BAD_NOTE 12 ttdefine A_KIOSK_ALERTED 13 ttdefine A_BAD_CARD 14 ttdefine A_PRINTER_DEAD ttdefine A i ;: .i.L.L '-j ' Tf- ' i i " " l 7.i'-iEuϋ >

_ ≤T3-

ttdefine A_SOME_OTHER_CARD 18 ttdefine A_CANCEL_CASH . 19 ttdefine A_CANCEL_CARD 20 ttdefi e A_CARD_ LU H_W IT 21 ttde. . e Pι_nnτ_CARD

.1 _ I i i , -ι_ l_-_-L - I I -.'_■. 1-11 . ij ttϋe πe «_CARD_ABEND 24 ttdefine Λ_CASH_ABEND 25 ttdefine A_REMOVE_CARD 2ώ ttdefine A_REPLACE_NOZZLE 27 ttdefine A_KIOS. _HALT 28 ttdefine A_SYSTEM_DOWN 29 tt define A_M0TE5_D0WN 0 ttdef ι n _CARDS _ DOWN 31 ttdefi e A BO l " H DOWN

H d e f . n .5 V CARD_ UJ A I T U

14 dε- 1- . n _: 'v __ϋϋGDI-. l£._Tr-IAI-H OU tΦde- i ne V_Llf-T_NQZZLE ttdefine V_I SERT_CARD 4 ttdefine V_REMOVE_CARD ttdef 3 ne V INSERT NOTE

I u ι ι .- -.1- ", I i I i J l. I I H. l_ - 11 I t I I I 11 I I i l l

_ »_?<*—

.Segment: 1 0000 to IDll (7442 bytes) .Segment:2 0000 to 021D (542 bytes) .Segment:3 021E to 08D5 (1720 bytes) .Total size is 25E8 (9704) bytes

CO1 0053 prologue

C " 1 005E epi1ogLIe

COl 0007 stk_αverflow

COl 00S3 -Sucbeg

COl 0084 '.Make_aLidio_show>

C01 0217 <say_hello>

CO 1 0255 < p Limp _n Limb er >

COl 02B3 <fliaiπ>

COl 0323 <initi lize>

C01 03CF < initial _error>

COl 0419 <usage>

COl 043B <set_my_timer>

C01 0464 <ιτ.y_ti rner_e.- * ρired>

CO1 0474 <c n el_my_ imer>

CO1 049E <timer_rLinniπg>

C 1 04AD <de1ay>

CO1 04C8 <oπe_clip>

COl 0526 <Timecode2frames>

C01 05C0 <Shows_length>

Uol 05DF <Reset new show."

- &S-

Be-* ι__r i!~ , i Λ| _ _.! ii H-._C.LI il 11_ .New_show_audι o_channel start_pl yer '.stop_pl ayer.- tι er_f lred.- se l _t I mer _e.'pι red ϊ- 1- i--' i '_ _ ' ■ i μ " ' i € 11- tsii-leci _ι.udio shom_αv * er e:: t_cmd play seel- - .Calculate timer interval

P J C1-" t.i __■ a., a s. LI ε

C hfeC i _ J '-T • I ~ 1 oad_-_.. ι ' 1 ( Ξ-. t tr"

1 DSu_ ._ h £ _ d I 5 \ pr * ιr.e_f or __-■ i deo__on ance L _ v i d>--"C. _orι__ρ.- _. fiie. cJ

• a. I I ^ i J _ I I _ I J I I.11 * 1 _. d

~-.~_.t~ \ J __ ' - d ~ \ • e

H 1 S_ Ll ιπ __n Litϊi F- r open_player F : 'lay_£._show Mai e_vιdeo_s ow T-ii..1 PC t shot * . i 11 ' "i i ' I 11 I . i r. i

- 3 £b-

COl OFSD Make_card_wait_video:

COl OFCB Make_show>

CO1 1054 <queue_clip>

COl 107C <find_clip>

CO1 1OCC <rotate_ 1ip>

COl 10FF <iπitialize_clips>

COl 1137 <show_over_eveπt

COl 1152 <video_seek_event>

COl 116D <lαg_video>

CO1 1184 <video_oπ>

COl 119B video_off>

COl 11B2 <event>

COl 11FB <1 eques >

COl 1-253 <sreqLtest>

CO 1 12B9 < d i s 11 o w >

Col 12ϋH - : .ιTιy_oρeπ

COl 130B <sleep>

COl 1351 <abs_sleep>

COl 1376 <set_timer>

COl 13E>D <strπcρy>

COl 1417 <strncat>

COl 1450 <strncmp>

COl 1483 <f lLish_input>

COl 14E2 <dregister_name>

COl 1683 < f i nd _ad i n >

COl

- -Ξ- -

Cυi l :. l ....

- S- -

COl 1896 <longjmp>

COl 1904 <nargs>

COl 191A <memcm

CO1 1945 <memchr>

CO1 1 72 < emccpy

CO. <for e adv>

— -^-

— ^0-

DOO 0008 <Eκ _allow>

DOO OOOC <Exc_pending>

DOO 0 10 <Exc_fp>

DOO 0012 <Exc_pc>

DOO 0014 Exc_permit:>

DOO 0018 <Exit_status>

DOO 001A <Error_status.'

DOO 00IC <My_tid>

DOO 00IE <Dads_tid>

DOO 0020 <Break_couπt>

DOO 0021 <My_tty>

DO'O 0022 sta _base

DOO 0024 <C d_flags. -

DOO 0025 <My_priori y>

DOO 0026 <s din>

DOO 0028 <stdout>

DOO 002A <stderr>

DOO 002C <Free_list>

DOO 002E <Eπd_of_free>

DOO 0030 <Fi1e_list

DOO 0032 <_Argc> OO 0034 stk_li it

DOO 0034 <_Argv>

DOO 0036 SAVE OO 0038 TEMP

DoO 0 U6 : 7Code f1α ε * . •-

__3"ol -

User _ num SroLip_num> Team_num> 'fτy_nιd> -.Dads_nιd ri- _cr'_ nid Rel a=e_num dp_save_area , Fstac. r

.Cal l_stack_ptr Segment_table_pt .Checl _poιnt_sp > User_spare -

good_morπιng good_af ter , qood_ evening p a / __ c 11 D l c e csr _choιc " _ ρetro_choιce card_auth / .al l_cash_ιn - ant_receipt credi t __receι pt r ep ι.Ct.__rii_ _ 3 e

D03 02DE <remove_your_card ' .

D03 02EE out_of_servi e>

D03 02FE <kiosk_told

D03 030E bad_note>

D03 03IE <bad_cardl>

D03 032E <fil 1 warn>

D03 033E -..r".o fiisu c _

D03 034E αther_card >

D03 035E <7cash_cancel

D03 036E <card_caπcel >

D03 037E caεh_abend>

D03 03SE card_abeπd>

D03 039E <kiosk_halt

D03 03BE : .hot_card

D03 03CE <declined_card>

D03 03DE <notes_down>

D03 03EE <cards_down>

D03 03FE ' printer_dead

D03 040E < b o h _d ow n >

D03 04IE <pLUT.ρ_nL τιber 1

DOS 042E < p urnp _π umb e r 2 >

D03 043E < p urnp _n umb er 3 >

D03 044E < pump_numb e 4

D03 045E < p Limp _n umb er 5 >

DOS υ46E '-. p L. rn p _ π Li rn u e r 6. ': -

DOS 47E p Limp _n Lim er 7

DOS 04SE spLimp_number8 ,

DOS 049E 'language!-

DOS 04A0 deposit_amount:-

DOS 04A2 -•hour>

DO" 04A4 fill_wιth_help

DO " . o4 o ρresei_ amount

DOS 04AS cLtei ng_ 11 me

DO S 04 A A ' 1 mer _p or t

DOS 04AC ' dis. _ιs_loadιng

DOS 04AE .send_events "

DOS 04B0 '.dave.-

DOS 04B2 .my_clιent -

DOS 04B4 cLirrer.t_f rame

DOS 04BS pl yer_m

DO " : 04DA player__αut

DOS 04BC ne.-t_com.nand

DOS 04BE current_coιrnTιand

DOS 0554 new_co.τι.τιand

D .' 05E A iπtti a . __ t r ap O: 061 c5_show OS o622 ciO_show OS 062C .cl5_show OS 0636 c20_shσw OS 064C cSO__show n,-. e Λ, 1 * . " ;^ =rιι.u

D03 O66C <c40_show>

D03 067C <fill_show>

D03 06SE <fill_help>

D03 069E <_clips>

DOS 079A <firstc1ip>

DOS 079C <1astclip>

E ' 03 OSIE 1oπρe _card_waι L.- ; -

DOS 0S2E <dr >

dc9/disk.h

#defiπe VIDEO_ORIGIN 90 #define AUDIO ORIGIN 90

typedef struct _clip C struct _c1ip *next; long start; long s o ? unsigned timing;

■ video_clip;

typedef struct -C long start; long stopj Cli •

■- I ?-, . ttdefine GBLGEN ttinclude "dc9.h" ttinclude "vars.h"

dc9/makefi le

CFLAGS = -S tWc.÷u SOURCES = Qcfiles OBJECTS = ©objects

dc9: *(OBJECTS) linkobj sort dc9.map f=l_2 tr copy dc9 /dave/dc"

global s. o_ vars.h video. o : disk.h audio. o : disk.h

-- -.. d c V / v fc 31T1 e r

ttinclude "dc9.h" ttinclude "vars.h" ttinclLide <timer.h>

static unsigned _my_ti mer_ruπni ng ;

eL _ ι m»ιι-γyy_ ϊi unsigned ticks;

set_timer . TIMER_SIGNAL, RELATIVE, ticks, 0, timer_port ); _my_t i mer _r unn i ng = 1 jf

_tiιTιer_eκpi red O

my ti er running = Os

ι_t-.πι_t.l iT.y . j. ιι.t__r C)

set_timer ( i IMER_CAN EL, RELATIVE, •-->, 0, tin * .er_por ) ; fny * ti er ruπninq = 0;

timer_running ()

>".i met- f unnino

delay( ticks ) unsigned ticks; C set_timer( TIMER__WAKELiP , RELATIVE, ticks ) ;

-- -

dc9/objects audio. o dc9.o globals. o my_t i mer . o one__c 1 i P .. o p i. aye . o ρri e_f or . o servi ce_dave. o vi deo. o

dc9/one_clιp.c

ttinclude "vars.h"

static Lir.53 gned _show_ti e;

•_t ■_■ t L .h-'t- "t .:-fι.fιϊ5i-ιd_b '.if f fe _er.d ;

unsigned l " ι ecodel'-t ra es ( )\

char κ-one_clιp( sta t_tιmecode, end_tιmecode, b, origin > long start_tι ecode, end_ti ecode; char *b; unsigned origin;

Linsi gned start = Ti inecode " __fra es c εtart_ L ι m cod ** - ,, end - s ,'

if c b = command_bu f er_end ) b ι-= tsprintf . b , "S"/.u. F-'V.us " , start + ΠΓIΠ. ΓI , end ι- oπ π

i.1 iϊ.iώ -I-- . i.i~i l — Stcl * I ) - i r t -.if π L 1 5

unsigned Timecode2fra e ( acode ) long acode;

'! I - J _!! I. 'LI ml.

_ » " 7θ—

seconds, frames;

minutes = acode / lOOOOL; /* 344 */ iT.insecs = acode ._ lOOOOL; /*- 344 */

trames = rπiπsecs 7. l L_; /*

return minutes * 1S00 5_Lunds 3 + fr_.me_>:

Shows lenqth C >

return show ti e + 15 )

cαιτιιτ.and_buf f er_end = πew_command t siseof C πew_coιTιιτ.and ) — 2 __ero ( new_coιTnTιand ., sizeof ( πew_coiTιmaπd ) .' ; snow ti e = 5

static unsigned _channel *

Set_new_show_aLidio . i ) Liπsi gned i ;

. eii ' i it'J. — • "

New show audio channel ( )

return channel

- T2-- ttinclude "dc9.h" ttinclude "vars.h"

static int seeking, seek ti e; ' * counts ticks required to perform a seek */

S S ' -l'.. OiS- * '-p;- . ' ?VI '_•'_!-__• uυii'.i.ci. ii-i i

star _ layer ( command . char *command; v r

sel ect_audio ( New_show_audio_chanr>el ( ) ) CDPY_3AFELY ( current_cαmmand , command ) ; neκt_command = current_coιTιιTιand; set iT.v ti er ( 1 ) ;

st op _p layer .)

. ι_i flier Lu i π 11 ιuf

cll ιι_t t_.1 iiiV " " L liner ) _

seek iπg = 0; ne-tt_command — NULL; cancel video on Dri ed ( . ' ;

-C char cmd C 30 3;

else if (dis. _ιs_loadmg ) chec. _+or_load_compiete () ; else switch . πe,:t_c.τιd(cιrιd, sizeo (cmd) > r

case 'P'_ play (cmd); break; cA-se 'S'_ see. (cmd) ; br eal- ;

Cc*•"-•- ** t>_ show o ' > 3

see. _tιιϊ.er_t.;,".ιϊred 1 ' -it _ I ι_ I. .. I uπq.. , * .i" Lr. ...1 r.<> * 11 . - -■. .

*J ;

if l seel _coii.pl ete ( ) ! ! see. _tιme = Tr-IREE_AND_A_ HALF_SEC0NDS ) r

_—-__~ϊ < * V -

else ne-- * t_ir.terval = QUARTER_SECOND;

seek_time += ne;;t_interval ; 5et_iT.y_tiiT.er Cne.-.t_ir.terv-al ) ;

__.fc_fc. k _ c dip' 1 __ t i _i- i- or i_.i_L.Li i j. n.

char pstat 17 15 3;

if ( piay r_status (pstat) ) return (pstat C 5 3 == 'R'> 11 (pstat 17 5 3 == 'E'); else r L'.rn u

b-a iL Lin __-ι ynt-fu _ι_ur

.... J- — I- _.. _ ._ _ ._ .... _ « ti .-v . ~y .-. c αLdLlL l_l Id! I*-'— 1 — Mi _. \U1_ ,

LIΓ. __■_. ι_-r .>__o i-has'i;

char *cι

if ( chan = * = _CLirrent_chan ) return .

5wιtcιι ( chan ) r _ case 1: c = l; break; case 2: c = c2; break; default: c = cl; break;

.

Ciiπ t'i __char. - chan;; fput( c, 4, pj aver_out . ;

sho _over ( )

if (send_events) sho _over_ event ( my_clιent > ;

char * b ;

ιr,L char

previous_command = ne::t_coιnmand:

/* in case we decide r.ot to dc it -*/

whι3 ? ( -ri----,,t command .... xne.t command ' -- '„ ' )

»Cϊ I " - *' r I C .. ' - C i 111.10' .1 il I ' i- -

-3-7^-

κ-cs+t = '\015' ; *cs = ' \0 ' ; if ( *ne> * t_command == ': ' ) ne;ct_commaπd+t;

retu n c;

μ char *ρ;

nsigned ticks,

Calculate_timer_interval ( ) ; extern loπq atol () ;

πeκt_commaπd = previDus_commaπd;

re— rocess this command *

:t_ι7ιv_tiιτ.er (QUAR iER_5_.EC-L.Nu> 5 -* after this timer expire, see:- time ■-=- QUARTER SECOND:; retur

CLieing_time = 0; /* only "cue" the first clip */ ticks = Calcul ate_tiιτιer_interval ( p + 1 ); f pu ( p, strl n ( p ) , ρlayer_out );

D;-_ me.

-3 * 7 " 7-

_ / >- thF initial "pla - * " romnianrl */ vιdeo_on( dave ); vιdeo_seek_event ( my_clιent ); cancel _video_on_prι ed ( );

CLirrent_ frame = a ol ( p t \ > -j = '- iϊi t ι lilt " 1 * ' fc J ι_ 15 ' ;

seei (p) char *p;

e..tern long atol ( ) ;

f ut (p, strlen(p. , plaver_θLιt ) LLirrεnt_ rame = atol ιρ t 1) ; s c I * ng = 1 see. _tιme = HALF_SECOND; set_.τ,y_tιmer <HALF_SECOND) ;

unsigned Calcul att__ti er_in ter n I ', * ?»'

/

e.iterr. long atol O; long frames; frames = atol (s ) - current_f rame;

' * di *■* ton i e -fr.'i" ci. t ~ < i.i i -un.

~ 78-

if ( frames < 0 ) frames -*== —IL; /* absolute */ frames *= 2L; /* times ticks per second */ frames /= 3L; /* divided frames per second */ frames t= 2L; /* round up */ return Cunsiqned) f ames;

#det11ϊt_ uiHι _ fWENϊ iE l H 1

player_status (s) chair *s;

int timeouts =

zero (; t i ϊ.t_ IΠDU .p ei i n J _ fput ( "?" , 1 , piayer_out) ; for (i = 0; i < S; )

I .'TII ...1 i"i--| '.pi, . " v' , _-'r

~. 17 i-t÷ 1 = getc <ρlayer_in> else

del ay ( OME_TWENTIETH ); if ( -t+timeouts >= 20 ) return 0;

return 1;

chec. for loaded dis. ()

:nt_ι_

if (p1ayer_status (status) ) if ( memcmp (status , "OOOOON" , 6)

load_the_dιsk (); return 0;

■turn 1;

e urn '.';

stati int load tries:

htz/cl f -ji" luπ co - et

if (load_trιes όO.

/ • should not tale a minute to oad a disl . * / _ / b- something else muit b_- wrong. v- '

di' . K 1 •__■ i Di. di α cj; return;

if (pl yer_status (status))

tus " 17

* l e

1oad_tries+-t-; set my timer (ONE SECOND)

is loadir.Q μ __.. i _. J. l .

ι_>_ι the disk

.1 aye;- ι__u .< i; set_my_timer (0ME_SEC0ND) load tries — 0;

-33\-

dc9/prι e_f o . c

ΦFinclude "vars.h"

static int pπ me_vι deo;

r" I.TMΪ i or / j deo on ( )

f n * ι ιne_ i d

cancel _vι deo_on_pπ med ()

ρπme_vιdeo =

return ρrι.τ.e_vιd *

dc9/service_dave. c

ttinclude "dc9.h" #i ncl ude "varε. h "

st tic int L'iTiD :;

servi ce_dave . dave, r > Linsi gned dave ; request *r ;

1 nguage ->value3; deposit_a.τιount ->value ; our ' .''V il Lll-.*-. i

D eset a oun — r — .-- v ■=. J "J

CLiei ncj_ti e /¥=liU.t_-i TC Tt l-'lT. ' 5ιιtn_> UU LICK ill _wi th_hel va.l Lie 5 ;

if ( r->valuei == VIDEO )

Make_video_show ( r— >value2 ) ; else if ( r->valuel =-= * - AUDIO )

Make aLidi D _s oω l r — >val UF— ) .

I- - '■ - ' l.ι •_!.._ . • .".if -«_.•-__ J. ►-.fi j : > '

-3S3-

el se r-.J-value6 = 0;

REPLY ( dave, r ) ;

if . Ji si _ι =_1 Ocidi nq " )

'. : I " . ι~ _ _ i J v C-J . ', ' !, el e switch < r- Opcode > r _ case PLAYER_STATUS. player_status ( ) ; brea case STDP_SH0W: stop_pl yer < ) ; brea case PLAY_SH0W: PI ay_a_show ( r ) ; brea case OPEN- oρen_ρ1._> er . r i ; i- f-j-i

Hi s_ ρuιτ.ρ_number ( )

ι_.ρ fi i _ρ 1 ayer request *r ;

my_clιent = r- -value! ; rj a v e =_ t -- ai Lie,, . sr. r ιι 1 i- L '1 <-ι i ue .

Pl y_a_εhow( r ) request *r;

:har status C 10 3:

D xav status '.atLl; if ( check_for_loaded_disk ( > == U )

show_over ( ) ; return ;

s itchC r— >valuel )

_._i5t. 'li-EU; jtu •_.> i a v e ;* new command C 0 71

Dt- ± !...fc. for vidt-u ι_>π ( . ;

u r t_ _Λ k "

:ase AUDIO: s o _p l yer ( ) s if < new_coiT.iT.andE 0 71 ) start_ρi ayer ( new_comiTiand ) breakr;

- ^5 " -

tt fdef GBLGEN

#defιne VARIABLE ttelse ttdefine VARIABLE extern

IΦendi f

tt l n el d s t . h

VARIABLE Ltnsigned language, deposi t_amoLint , hour , fill_ ιth_helρ, r e s e t __ a α u nt , c LI e i π g _ i ,

I " j I " . Ξ I " j.. _j j- t_ „ di i __ l s_l oad i ng , send_eyent ,

. nl \ ± Mi '!_ i. i or.g -ιrι-!__nι

VARIABLE FILE *player_ιn

*ρi ayer_out ;

ttdef ine VIDEO COMMAND LENGTH 150

r.ι;fι._! __ iι _ ιt - a ι ' ι ~ ■ ■ tn n _• . i ■ >

πew command17 VIDEO COMMAND LENGTH 71

ttdefine HALF_SECOND 10 ttdefir.e 0NE_3EC0ND 20 ttdefir.e QUARTER_SECOND 5 ttdefine THREE_AND_A_HALF_SECOMDS 70

'I-JC Ϊ i fit ! *■■ = _ i _.!' .__.-". X .- " '< •' iπi ti ttdefine NOJDE ICE 2 ttdefir.e USAGE 3

VARIABLE jιτ.p_buf ini ti al_ trap;

- 3S " 7-

ttinclude "dc9.h" ttinclude "vars.h" ttinclude "disk.h"

unsigned c5__εhc>w 1771 = C 15, 10, O 3? i l i.ij fit J ._ I ( ' : I >_ι L i — - J , _J ., j -j .. -J 3 ' ' unsigned ci5_show Cl — I 3O, 5, lb,, 5, O ■ , unsigned c20_show C 771 = C 30, 15, CO, 10, 0 3;

unsigned c25_show C 71 = C 45, 15, 30, 5, 5, 0 " J; unsigned c30_show C71 = C 45, 30, 5, 30, 5, 15, 30, O 35 unsigned c35_show CD = C 15, 45, 5, 45, 5, 30, 15, O 3; unsigned c40_show C 71 = C 15, 45, 5, 45, 30, 15, 5, O _ ;

unsigned til__show Cl = C 15, 30., 5, 30, J , 5 „ <i_■ , JO, 0 3 unsj.qr.ed ιi3_help Cl == C J „ 5, 3-.-. If., "r. +5, ιυ u J ;

Vιdeo_ciιρ _clιpε C 71 = 1

MULL,, OL, OL, 0, /* "top" * NULL, 12L, 5018L, 45, * torch, J -v/ MULL,, 5110L,, 5902L, 10, -' . h,-,b-- le-rl 1 /

NULL, ] 2927L, 14605L, 15, " ho.--.e- * -

NULL, 14608L, 21519L, 30, / * bluenose 1 */

NULL, 1700L, 22904L, 10, /* glass */

NULL, 23004L, 24308L, 15, / * torch 2 */

MUI L "4Z I L . 31 ".t -'l , " '' ', , ,t-- . >-.

— 3<5S-

IULL , --> 1 rt'- i ι_ ,, . , ioι L. _J ,,

MULL, 31809L, 40325L, 45,

NULL, 40504L, 40914L, 5,

NULL, 40925L, 44002L, 30,

NULL, 44016L, 52712L, 45,

NULL τ MULL.. _U.

NULL, 60327L- 6491IL, 45,

NULL, _65003L, 70312L, 15,

NULL, 70405L, 73306L, 30,

NULL, 73420L, S2504L, 45,

NULL, 82423L, 33000L, 5

s-f irstcl ip _cl ip;

μ - = Ci I'

static ip hel C 2 71 = 3. jl_ , ~Uι_l_. -Jl_ , ?2217L

En o 1 i εh — I- r er. c r */

i"-^,-- \ '- i i .— ..-i ι-ι.-- . i r, ,ι .-,ι-,ι ΠC ΛI -, ,

C. •_> Oi.'iL, Dfϋ'.JiL., O * ' i J __.1_ , D _J ϋ U i.' _ ..- 5

C 111704L, 112127L, 111704L, 112127L static Clip iπsert_cardC 2 3 =

C 112306L, 113010L, 112306L, 113010L 3-; static Cl J p re.t.ovs_card 2 7! = l. 11UHJ- iL _ 1 ; '._-.' „ x i • '..-__._.!... _

static Clip insert_nαteC 2 1 =

C 92418L, 93402L, 93512L, 94803L 3; static Clip goodbye L 2 71 =

C 121117L, 1 100L, 122200L, 123408L 3--, stat. c Clip pay_. los 17 2 TJ =

; L235 OL , J 2 11OL , 11 51OL„ L '. I 1: .1. 3 s

un όi gned 1 onger_card_waι t f. 3 - C 5, 10, 5, 30, 15, 0 3 *

Mai _vι deo_sho ( program ) in program; r-

Clip *c; unsigned *3el ct_show . . , bucl'5 = deposi t_amoLin t ■' LO ,

char v-p = new_command;

it < program == V_FILL )

'_»__ t _ 7 " . c. w _ - " • r i IΛ, _ ( I Li _ I ϊ ' J i f i f l L 1 __ 3 th_heJ p i

N il e_ -! 11. _he I ρ_ show ( p , V I " DE_Xt_ Dr.1 l_ L M > :; el se

Maie_show( Select_show( bucks ) , p, VIDEϋ_ORlGLN J; return 1 ;

_ 3 c?0--

l-f ( program == V_LONGER_CARB_WAIT ) C

Set_new_show_audιo . 1 ) ; Make_shαw< longer_card_wait, p, VIDE0_0RIGIN );

SWltch . pt ι_ιyi- a.'

case V_CARD_WAIT_ c = card_waιt; breai * case V_LIFT_NQZ2LE_ c = 1 ι-Ft_nαzr_l e; brea. * * case V_INSERT_CARD: c = ιnsert_card; breai ; case V_RE r iO'v'E_CARD : c = reπ * .θv * e_card ; break; case V_I .SERT_r-.UTE_ c = ιnsert_note * , brea! t rza≡≡ V_GOCDBYE_THAN'l _V JL__ C = gαo b- ** - b a!- - case V_P'ι-ϊ\ _1 iuSr _ c = ρav_t i osi- ~ brea! , de ault ; return O; br t__cil- 5

case '-_GQOD_3. E_fΗAιir _.Q * J. case V_INSERT,MOTEs case V_CARD_W IT: Set_new_show_audιo< 1 ) ; brea. ; de-Fau.lt: Set_πew_show_audιo \ language "" 2 : 1 ) ; brea► n

c +— language; one_clip( c--start, c--stop, p, VIDED_DRIGIN ) ;

return 1;

ι.ι r i _r i irn- ~> " Ξ> ι__- J .- ..- t- _ C.-. I h iι_! =* >

r

Linsiqned *-s, type;

type = bucks / 5; if ( bucks "/. 5 '= 0 1 type++;

case 0: s = ill_show: brea. ; case 3: s = c5_show * breaI- "

Crt^c 1 _' - -» — 1 a -'_ '-..how!, Dl~Dcλi i

_. _ _ _. 1 _r _ — —

... c-l-JtJ ] -J _ .- — l5_shows brea. ; as 2ϋ_ c. — 0__cnow; brea. ; case 25ii s = c25_show; breai ; case 30: s = c30_show; brea. ; case 35: s = c35_show; brea. ; c c 4')s cl .. i a' 11 r : <.i! rho s 111- eύi

-3fl _-

return s;

Make_f ill_help_show ( bu , origin ) char *buf _;

char *oπe_cliρ( ); Video_clip *father,

*c,

**f ind_cl ip ( ) ; Clip *ch - help;

if ( ( father = *■ find_cliρ( 5 ) > = * = NULL ) r e t L I r π 0 _ buf = oπe_cliρ( c—>start, c—>stoρ, bLtf , origin); rotate_clip( father ); ch = l nguage Y c -"- 1 _ ch; ut = oπe_ciι . ch— ≥tar , ch-x-stop ._, but . ori in ) ;;

t__XLι. π π«ke_i.ι01. i Tii__iiEip, ιτ , _->r g_.ιι ) ;

Make_card_wait_video ( wc, buf, origin > Clip *wc;

-3=13- i n ;

but - one_clιp . wc- 'start, wc- stop, buf, origin > 5 return Mai- e_show . 1onger_card_waιt, buf, origin ) ;

I '"l . - ' a- . u Sl " . rj.' J cπ r ''buf ;

unsi qned ; char fe-oπe_clip( ) ;

•<' d o_ clip J-- -T at her ,

JΓ < : = ; show 17 l 71; 1 ++ .

L-i ' -ι a then

bϋ -T = one_ c 1 _ p ■* - _•"- r . ιr + "_. -.f-'j.. , L'Li-i ., 't~ ] Ql lμ ; rotate_clιp( father > ;

*buf - '\o

queue__clip( c )

Videα__cl ip *c; r

if C c == NULL ) / * bug */ return;

lastclip = c; c->neκt = NULL;

Video_clip *find_cliρ( seconds ) /* find clip, return father */ unsigned seconds;

*tather:

f at her = -first clip; for ( c = t at her — ne.-; t ; c; c — c~. r. ext )

i . c tiiτting — = seconds rcsK _

return c == NULL ? NULL : father;

-λ- Linliri. a clip's s ri and puL iL at the b_ * ιι_. u-f ti.e list #.' Vιdeo_clιp *p; r

Video_clιp *newlast;

i ( p =« NULL 11 x hug * l r ' .-_', ' --' l " I { < ~ ' '— ' - — ' f I L " . I . " , I I , t • ' l I ' , ' ' etLIi" ι"ι ;

ρ~ net = new last- n ct; queue_clιρ . new] ast ι;

l n t l al ι:e_cl ιρs ( )

_ n i

for ( i = 1; i sizeof . _clιps ' •' sizeof ', Video clip ) ■ , i +-t- ) queue_cl tp( _clιps + . . ;

i i _ ι!ι CL L! I L _.UL

lip

pπr.tf ( "First = /'.O- Last = /.04. ' \n\n", tirstclip.

for ( i = 0; i < sizeof (_clips) / sizeof ( ideo_clip) ; i-t-t- ) Dump_clip ( _clips + i );

Duιr-p_clip ( c )

Video_cliρ *c;

p r~ I n t "i"

C "Address 'Λ04κ Next X04κ Start 7.5d End C5d Time X5d\π", c, c -/-πsxt 5 c - 5tart, c — .- : stoρ, c cιmιπg ) ;

#endi

-2£n-

>.ιm

ttinclude dc9.h'

purrιp_morιey_aLιdι o ( )

announce aL'dio', L r.qαaqt. , hour ) unsigned language, hour; r

return prequesL ( PLAY_SH0W, AUDIO, A_ANNOUMC , . anguaqe, hour , 0 ) ;

p_llΩ|'_ l l l"'t I.'V _I I.. .! J l~ ' 1 I II lϋ'-ia - tr i riM,-| i _ | 11.1 |[|D -• \ ' un s- qned Lanquaqe, pu p_nuιt.ber ;

! _ _ ] _ , „ _ „ _ _ , , , „ _ I r-t i r r— • t t ι- r i - i 1 . - **■ r - r i iiiir. K ι . . γ- r— r*- t - , , - -

P t- J LLlr r . r t- | ltefS- L r Li n __orv-j- 4 n i iuu i u, J UI if _ PI ι_ I' i ._.•_____,_ . , . eΛi lyU i t. ,

ai " L!_ i i'3 i ct'__auϋ i o ^ L =Λ n g u a y £■ 1 u π B 1 g n ed i an g nag e ; u rot urn prequest < PLttY_ SHUW , AUDIT., A. TΛRD. Cl IDTCE , 1 -mquaye.

all_cash_in_audio . language ) unsigned 1 nguagej

return prequest C PLAY_SHOW, AUDIO, A. .IN, language,

receiρt_no_credi _audio ( language ) unsigned language; r. return prequest . PLAY_SHOW , AUDI O , A_RECEIPT_NQJ7_REDIT , language, O, 8 );

. ,__1 pt_i_rt_ l di t__*Lϊdi ._. ' . 1 _'.! .y ici i.. . unsigned language?

return prequest ( PLAY_SHOW . AUDIO, A_RECEIPT__CREDIT_DUE,

1aπguaqe, ϋ, α )

ι_>__.y_ι_!iι_.ii_t._dLi. ii_ ! . lanyU ye ) unsigned language; r u return prequest C PLAY_SHDW, AUDIO, A_CABH_OR_CARD,, language , S ) s

ρetro_card_audι ( language ) unsigned language; r

return prequest ( F-'LAY_SH01AJ „ AUDIO, A_PETRO_CARD , language,

O , S > *

I_<LI t_ι . I _Ξ_ ' i" v i ._ _ ' _aι.ι.J L c. ■ I ai iDLi q ) u n __ _ α h e ■ j ] n π u a q _

return prequest ( PLAY_3H0W, AUDIO, A_OUT_ . OF_SERΥ , ICE,

1anquaqe,

ufl r....'Xe_ ιudLo l uaue .

LU I = > . ljn.?,j L ' 'i- .' -. fit. '

return pregue=Lι PL \ _SHϋW „ AUDIO, A_BAD__ OTE, ] armuago „ 0 > ;

I i i " . I __ ' li * "'. " L Pϋ rt' ιU 1 I . I. " M 1.1 -.11 ιι- 1 un j. i qr..5d 1 juaq " .

rrturn prequeet > PLΛY_SHUW, AUDIO, A_. IQG. __ΛLERTED, i an uage„ 0, >

-f UrCO-

bad_card_audio( language ) unsigned language; C return prequest ( PLAY_SHOW, AUDIO, A_BAD_CARD, language,

0, 0 ) ;

pr iflLt'. C3t_fS J__ai ii Ϊ_J i ±ciinylΛcΛyfcf uπsiqned 1 nguage * rι_. return prequest . PLAY_SHOW , AUDIO, A_PRI TER_DEAD , language,

O , O ) 5

μL ιιu___. _t*l i_it_.___.Lld i u . 1 eir.yLiage .' unsigned language; -_ return prequest C PLAY_SHOW, AUDIO, A_FILL_START_TIMEOUT,

r ep I t'_ «=. r __ V \_ \S' _ L_rfr~d __ Lid i CJ I c_ι iCjLtScjfa unsigned Ianguage§ r

return prequest ( PLAY_BHOW, AUDIO, A_CARD_REPLACEMENT, langLiage, 0, 0 } ;

-I OI-

rl u li l ,-ιfι 111. - *" -■- unsigned l nguage;

return prequest ( PLAY_SHO , AUDIO, A_SOME_OTHER_CARD ,

1 anguage , 0, O ) .;

uris L gnι_.d J iriguaqe;

return prequest'. F'LAY.SHO , AUDIO, A_CANCEL. SH, language, 0, 3 )

._ rl I I . I ' I J. I 1" . I -.-. ,_ι..ι J I . I J anquaqe

'.1 r 1 ~ ι J q n e ι.i 1 a 11 q ι_ι a q _. i

»tu n pr quest ■ PL. v, _SHO , AUD T 0 , A_CANCEL _ CAfω , language, o. a >

c r cii.l-ii i-i'i ii 1 ' 1 iriu.i..' Cit-

'. ' I 1 '_; 'J 1 I l - J I '.1 I I ..I l I c . I I t?

ret ur Γ. r eqαest ( PLA Y_SHOW , AUD I D , A_C RD_ Al IT! I_ W I T , l nciuage, 0, c> > ;

1....1 n

— -+02.-

unsigned language; C return prequest ( PLAY_SH0W, AUDIO, A_HOT_CARD, language,

0, O ) ;

n * --. a rf-Pϊ0i -c-l'._!' "" .'

return prequest C PLAY_SHOW, AUDIO, A_DECLINED. ± cinguage ,

O )

card_abend_audiD . language )

return prequest C PLAY_'__HuW, AUDI'ϋ, A_CARD_ABi__ND , language, 0, O } ;

ι_ __~ri_ai_5 ' __'! ιd_ a._!..._i i -! -. _. ώι ϊy i-iay Ξ' i unsigned language; r

return prequest . PLAY_SH0W, AUDIO, A_CA3H_ABE D , language, 0, 0 )

! ■" &[...1 ιr..ι_e i.|—ι_. _. _. ___ __ fiU,. ' , * , -_• . .:. a _.■L;_.•"—;•

r

return prequest ( PLAY_SHOW, AUDIO, A_REPLACE_MOZZLE,

1anguage, υ, 0 ) .

1 ιD c i _ t' ii t fi'.l J u ' j ιl"ιi-iUΛC|& "• υnsi . . iang g.p",

■turr. Dr-.qu_.5t < PL Y_SHOW, AUDIO, tt__i IOG. __HALT ,

1 anquay , U , 0 )

. y st oϋi_ ϋwn_audι o i language ) ' π __ i ci n ed L a n q u aqε;

-. i i ii i , J . i.'i/i- ri i r ι_ i- 1 ' _ i.-l 11.. " ' ,| ι ii 11 _ ,_. „ t-ι i _ i __ ι ui " „'. ! H

1 anguag , , 0 > .

a t _' i ,-- -;I ,_! I--. , (ji ι_, || -| cll-'l-ll C3 . 1 H-|qUclO p

i-t'turr. prequ.r-_.i_' PL \ ..SHOW ,, AUDIO, H_MC.rES._ r.Wlvi,

1 anguage , 0 , 0 > ;

ι-δt ι.l i c-'ri ti iJn ii _<ιLu.liu( Language )

return prequest ( PLAY_SHOW, AUDIO, A_CARDS_DOWN, language, 0, 0 );

return prequest ( PLAY_SHOW, AUDIO, A_CARDS_DOWM, language, 0, 0 ) ;

rernove_card_audio ( language > unsigned language;

return prequest 1 ; PLAY_SHO . , AUDIO, A_REr.QVE__t7.AR70,

1 nguage ,| -- t

dc9/int/c-f i les

audios. c int 1. video „ c

dc9/int/iπtl . c

#include " Λ dc9. h'

static unsigned dc9; extern request dr

unsigned port, client, davis , event_mαde;

dc9 = detach (port) ; preqLtest (OPEN, client, dave, event_mode, 0, 0)

top video show ()

u r s_rq Li t. =- 3H_

ρl ayer_status_ι--equest ( )

! t_u)Lt__.i O,

preqLiest ( opcode, type, show, language, dough, cueing_tenths ) unsigned opcode, type, show, language, dough, cueing_tenths; r

dr « opcode = opcode

_1 l~ .-, V e~γ j. Li '--r' s -- '■ v (__ '-'

■_* i~ .. v ΪΪΛ .1 t (__? . ' - -- π t--[

dr. values — language; dr.value4 = dough; dr. valueS — cuei ng_tenths;

SEND . dc9, _.dr ) r e t. LI ι- n d r . v a 1 u e __

- *cfc -

dc9/int/ ake-file

CFLAG3 = -S +Wc,+u SOURCES **** @c-files OBJECTS = ©objects

■• "--directorys $■<OBJECTS ' ;

i " ' "■ '.' , , i ' I'I II -W ni 'I ' ll S . c_

1 : n l ude new dc9.h"

pLi.τιρ__money_audi o <

.-'[,! > ., ' > )

announce^ audi o c l nguage, hour ' unsigned langLiage, hour; r _ return prequest ( PLAY_SH0 , AUDIO, A_AMNOUNCE, language, hou , O ^ ;

' .'.!. l"-. i .i.i. it ' ll ir ■lϋ ϊu ' I .ιιι IU-i' 'i _, μ' '_' f7'| " " _ r I I.I . M h & -- unsiqr.ed language, puιτ.p_number ;

return prequest < PL Av_SH0H, AU LU, A_PUriP MUM EF' , language, jjUhlp _ I " , |-|C'C. ι " , -■' ϊ "

~ _l_ι hoi ι_'_ ai idi c> ( lai.quaqe unsigned language;

returr. prequest ( PLAY_3H0W, AUDIO, A_CARD_CHDICE , language,

_ 4-IO-

-_

al l_cash_in_audio ( langLiage ) unsigned language; r

returr. prequest < PLAY_SHOW, AUDIO, A_CASH_I , language,

0„ 15 > _

receiρt_no_credit_audio ( language ) unsigned l nguage; r

returr. prequest ( PLAY_SHOW, AUDIO, A_RECEIPT_NO_CREDIT, language, 0, 15 );

receipt credit audioC lanqu.

returr. prequest ( PLAY_SHOW, AUDIO, A_RECEIPT_CREDIT_DUE,

15 ) _

Ltnsigned language;

returr. prequest ( PLAY_SH0W , AUDIO, A_CASH_OR_CARD ,

1 a π g u a g e , (_> ,

petro_card_audι ( language ) unsigned language; C returr. prequest . PLAY_SHOW, AUDIO, A_PETPO_CARD, l_.nαuage, 0, .5 )

P(.ι * _at_. IDS. _audι o ( l nguage > unsigned lanquaqe;

returr. prequest ( PLAY_SHOW, AUDIO, A_. IDS! _3ALE , language, 0, 0 )

:>ut_ _.. iiTv'icf. ddiD 1 3 a qua no unsigned language;

_turn prequest < PLAY_SHOU. AUD ED, A„0UT_DF SERVICE, i ar.quaqe .

bad_ not t_ j _c ιdi o { 1 anqLiaqe ) unsigned l nguage;

\ r. return prequest i PLAY_SH0 , AUDIO, Λ_BAD_N0TE, lanuuaqe. 0, 0 )

«

kiosk__alerted__audiα ( 1anguage ) unsigned language; r ~ __. return prequest < PLAY_SHOW, AUDIO, A_KIOSK_ALERTED, language, 0, 0 );

bad_card_audio ( language ) unsigned language; r

return prequest ( PLAY_SHOW, AUDIO, A_BAD_CARD, language, 0, 0 );

ρrinter_dead_aLidio ( language )

Ltr.si gned 1 anguage ; C return prequest ( PLAY_SHOW, AUDIO, A_PRINTER_DEAD , language, 0, 0

μL.m _.„. _t_-l st_-__:.Li.di o . .1. an Lt-s >_)•__ .< unsigned langu.age; r

return prequest ( PLAY_SHOW, AUDIO, A_FILL_START_TIMEOUT, language, 0, 0 );

replat e__ yDur_uarci w udi o { 1 nguage ) unsigned 1 nguage; r

return prequest . PLAY_SHOW, AUDIO, A_CARD_REPLACEMENT,

] nquage , 0, 0 • ;

> 11. ► r _ .. _ ' i i _ < - 1... i 1 i . ' 1 _• i • i ' i . i cl ι_-| c >J unit qned L nguage; r

return prequest C PLAY_BHOW, AUDIO, A_SOME_OTHER_CARD, language, υ, 0 )

c-L i t l I 1 a11ι_fLIaqe )

return prequest 1 PLAY_BHOW, AUDIO, A_CAMCEL..CASH,

] anquage , υ, 15 )

III " -.'! . ζ- I , ... _. i."j-ι c_ ! a cju ge . ι.ιn_: ι qni _' ! _•ng._. _,y , ;

return prequest ( PLAY_SH0 , AUDIO, A_CANCEL_CARD , l nguage, O, 15 ) »

caι ** d_aLtth_audi o ( l anguage > unsigned language; *€ return prequest < PLAY_SHOW, AUDIO, A_CARD_AUTH_WAIT, language, O, O );

unsigned 1 nguage;

returr. prequest C PLAY_SHGW, AUDIO, A_HOT_CARD, langLtage, 0, 0 );

d ec I i π ed _c ar d _ aL »id i o ( 1 an g— uag — e ) unsicrned Iaπquaq ;

return prequest PLAY_SHDW, AUDIO, A_DECLIMED_CARD, language, t ) , O )

unsiqnsα ianquaqes

returr. prequest ( PLAY_SHOW, AUDIO, A_CARD_ABEND, language, O, O );

unsi gned L anguage; r

return prequest ( PLAY_SHOW, AUDIO, A_CASH_ABEND ,

1 anguage , 0, 0 ) ;

I III ιq JC li-

r eturn pr equest . .HOW, AUDIO, A_REMOVE_CARD, l nguage, 0, 0 .

repl ace_nozz 1 e_audι o ( language ) u r. s j q n e d L i -> ci u ge ;

-eturn prε-que=t ( FLAV_BHϋW, AU lL 1 , ri_ι-._ FLALL- Γ _NU ILE , language, 0, 0 )

u"._._ qr.Ci . :-.r" * ag !

returr. prequest I PLAY_SHGW, AUDIO, «_ 1- I OS. _HALT ,

1 nguage , 0 , u ) ;

un≥igned 1 nguage; r

return prequest < PLAY_SHOW, AUDIO, A_SYSTEM_DOW , langLiage, 0, 0 );

note_reader_do n_audi o C langLiage ) r

return prequest ( PLAY_SHOW, AUDIO, A_NOTES_DOWN, language, 0, 0 );

card_reader_do n_audio ( language ) unsigned language;

. t e_ ___.,L.i,-_ n_. _ p... _.q ..L ._t.5 -.J. '. r r-.i L-H iw. i/ _ —__-.riiι—_.ι., 1 . l , ι Λ-ιiι |_r_ \ fτ ___.r ι_ι, , i r-.i . ι—_ ..!.--.. Γr-..TL!.-—:__ -_ τL-.'rL-..'i'-..iiιi , language, 0, 0 );

b_jth_r eήder s_duwr._ iudic language 5 unsi ned 1anguage; -.. returr. prequest C PLAY_SH0W, AUDIO, A_CARDS_DOW ,

1 nguage, 0, 0 ) ;

-L P-

dc9/int/ob jects

audios.D int1.o videos« α

i n t v i f _. o s « c

#include " ""dc9.h"

card_auth_video ( language ) unsigned language;

_r

longer_card_auth_video ( language ) unsigned language; r

retLirn prequest ( PLAY_3H0W^ VIDEO,, V_LOMGER_CARD_WAIT ,

1 a n g u a g e , 0 , O

goodbye_tharιks_video ( 1 anguage ) unsigned l nguage; -_ return prequest ( F"LAY_SHOW, VIDEO, V_GOODBYE _ I ' HA __ ' . GL

1i-ft_nozzle_video (language) unsigned langLiage;

i L rt . " ■ -:•! (ΪJi'i „

J unquai-i' . i ,

reιiιove_card_vi deo ( language ) unsigned language;

* t_ ._ Li rTi μ ι" t. '- ' G ;f.7Mθvr r ΛRD ,

ι nsert_card_vi deo l language > unsigned language; r _ return prequest < PLAY_5H0 , VIDEO, V_ INSERT_CARD,

1 llJit'f L_L i i [ v L dt- j i . I'-l ui i -- . unsigned language; r

return pr pque<_:t . PL Y . ^HOW. VIDEO, '-'. I SERT MOTE,

J _. r πuac-ι=; . > • ,

f 111 _v i deo \ language, cents, ιth_helρ ) unsigned language, cents, wi th_hel p; \ r

return preqitp∑.t ( P AN HHH , VIDEO. V FILL , J .mαuaq.- „ en l <_- „

lift_and_pay_at_kiosk_video ( language ) unsigned l nguage; C returr. prequest C PLAY_BHOW, VIDEO, V_PAY_I<I03K,

1 _-.n ia.ae, 0,

everιts/eαι.ιeue. c

tt include "event. h" ttincl de tasi _rrιsgs. h H _ r. _: I .-' ι .? '_- '" 10. l * ι r l 1 1 1 C I U 0 β ' " ■ . ! >

M-d e f L n ι-. UEUE_ S I Z E l

char t nsuE. T OUEUE_SIZE 71;

Lins. gr.ed put_ιπ . ta. e_out ;

1 - e q u e s cendi no;

, r . i v. ) 1 π a gc; char 1 , -dfij C J ;

in- r c<"i> I^ =_ t ._.r

a 11 __

1 * -- , _!i_ι_ι< J _ ( .r - -- r<Fl r I VF " I -I 'I

case GIVE_ME_EVENT: give_me_event (requestor, _.r) ; break; default: event_arrived (requestor, S.r) ;

initi lize ( )

int i ; char -*calloc ( );

i , . 11 1 . ____ 11 \ -

J. _j-g__!__l- 1 '. =>ι_.a. a- . ; for ( i = O: i ' QUEUE_SIZE; i-i--*- ) queue L i 71 = eal loc (1, sizeof < request ));

event_arri ed (producer, r) unsi gned producer ; request *r;

reqLtest_peπding ) ■ ■"' * dave s waiting or" an ** ?ver.t -x-

- 2 -

REPLY (dave, r , ; / * * so send it to him * / request_perιdιng = υ; /if- he's not waiting now */

el se enqueue_ever.t (producer, r) ; /* save it for dave s * -/ .product?''' , r > .

F'_ ven t irsquestot , r> unsigned requestor; request *-r ;

queue__ernρ t v ( .

"hen r- ε-r t read to o * /

deqLιeue__event 'r ' ',ι ' * get thr- e er it * ■'

REPL V ( r eq Lies t or , r t /* tell dave all about it * /

.-f-'.'f'.6' i _ρe. ι ι nr. : - 1 , .'* εav thai, ave => cii tinq !L.| ocl pdt *-*. dave - requestor; .' >* remember his tid */

-«A-

unsigned producer; request *r;

if ( queue_-f-_i.il ( ) ) log_eq ("overflow");

memcpy (queue Cput_in3, r, sizeof (request)) put_iπ++; if ( put_in >= QUEUE_SIΣE ) put_in = 0;

dequeu. (r iLte t

memcpy (r, queue C take_out j, sizeof (request) )

ake O i".

queue_fLill ( )

unsigned new_ρut_ in;

.-,(?._-_ riL; ι ..", — Dot I :ι

if ( r.ew_put_ιn = DIJLUE_31ZE ) new_ρut_ιn = 0;

return new_put_in == ta.:e_out;

t etur r. t a. o o_ p I t _ l n ?,

events/equeue. map

.Segment: 1 OOOO to 0775 (1910 bytes) .Segment:2 0000 to 00A5 (166 bytes)

.Segment:3 00A6 to 0173 (206 bytes. )

Ol 0053 prologue Ol 005E epilogue O1 0067 stk_oveι-f1ow

COl 007D <e.- * it>

COl 0033 Φucbeg

CO1 00E9 <initialize>

COl 0142 <event_arrived> u1 υ139 sgive_me_evεnt

COl 01C2 <enqLieue_event>

COl 020C <dequeue_event>

C01 0243 <queue_ful 1 >

COl 0271 <queL'.e_e.τιpty>

COl 023B <log_eq>

C01 02A2 <1request>

COl 02FA <strπcpy

COl 0334 <strncat>

COl 036D <strncmp>

Co1 Ϊ> AU -dreqister_naιte.•-

L.O _ ϋc>4ό --.'-ii-d admi

π o n n r π o π π n n n n n π π π π n n

o- o-

H . * ".

- W&

σ σ σ ! *? 'Ξ 9 ? 9 1 3 ^ , Ξ i I 5 , 2 5 l 3 9 | - . Q r ' ' i n n n n i '_.' ' _. *— ' '.. _. '_.' *—. 'C' ' '__' '__' ' '_ * ' ' - ' * T' O '-.' '-_' ' -"* '— L !--* •- — -^ i — y H- H* I— L

O O '•_-' '__ -. O O O '•_.' ' ' ' ' '_.' __' C a ~.~ . ■ "" -. *" -* .

O O O O C O C C. O O O O O O --4 "-■) -J --.I -v! 0- tJ- 0- 0- t ' ΪJ iJ H- i— 1— a -*. y y r- r rt ,____, Q O O CH '.4 •-.• C Η Η Hi IH iJ y C PI ,-ι t. -,ι fi r. i C " ' CO -t * - ._= O ( J\ -il n r Cr O 3 -fc> m CD

i-r 2 to c - rπ ,-η rπ rπ m rn rπ π c c 3 rr =' r π T n T ∑ - 11

& - " . a. - - - - r: -- in m ID ID iti " . iti in ID T ID π i rti a ; -. n n n n n n ID ID ΞI ~~ 3 ~ ι * j i— H * H H -_■

— rt 0.1 'ji π- α rt > i ι i ι I ι ~~ ui a ri n a. in a rt a i rt — i H -- i u Ό -t, τj > σ i i to TJ iti < 3 1 ID i σ - i rr i ■* ' ID ri TJ ti H- ,J in w rt < -■ p. -α ι s a> n - . * - rt ι H- r in Ό -_ H" o 3 in in o a rt _ 3 a o >n ιι i m i

ID P . 1 ' ,-r H H £ rt _

3 .-r 1 rl- r+ P i'l

OO 0026 <stdin> OO 002B <stdout> OO 002A <stderr> OO 002C <Free_l ist> OO 002E <Eπd_αf_free>

" " -IFil e_list..'- OO 0032 <_Argc> OO 0034 stk_lin.it OO 0034 <_Argv> OO 0036 SAVE OO 0033 TEMP OO 0060 <Cod _flags> OO 0061 <User_nu.τ.> OO 0062 <Ercup_nurn> OO 0063 Tean._nu,τι> OO 0065 <My_nid> OO 0067 <Dads_πid>

DOO 0069 <My_tty_nid OO 006B <i y_cd_nid>

DOO 006E' <Rei ase_nuιTi:- OO 006E <Mdp_save_area>

DOO 0070 <Fstack>

DOO 0072 <Call_stack_ptr>

DOO 0074 <Segment_table_ptr

DOO 0076 :.Check. point _sp. i_> " >': O y -..User sp -<■" -■•

D03 00A6 .queue.

D03 00C4 put_in ' -

D03 00C6 "ta e_out>

D03 OOCϋ d .e O.' o r-ι .-fi..,,? _'. _ r,_'i"._iι ri.

D03 OO..fc dr

f- y^ZL-

events/event.h

ttinclude "/user/steve/dave/dave_request.h"

ttdefine BI E_ME_EVENT 0

ttdefine CMT_EVENT OnOOO1 ttdefir.e PLAYER_STATLtB 0x0002

#defiπe SHOW_OVER 0x0004 ttdefine BCREEN_TOUCHED OK0008 ttdefine TOUCH_STATUS 0x0010 ttdefine PUMP_EVENT 0x0020 ttdefir.e BULLOCH_EVENT 0x0040 ttdefine NOTE_E ENT OxOOSO ttdefine CARD_EVENT 0x0100 ttdefine ST C.-._E EMT 0x0200 ttdefir.e PRINT_EVENT 0x0400 ttdefir.e P0B_EVENT OxOBOO ttdefine CONTRQL_EVENT Ox1000 ttdefine PRΪCE_EVENT 0x2000 ttdefine VIDEO_SEE _EVENT 0x4000 ttdefiπe PDWER_EVENT OxB000

ttdefine CNT_TIMEQUT ~ Z ~

ttdefine EVENT_QUEUE "/dave/equeue"

C a-

events/int/card event. c

ttinclude """event, h"

card event (task. unsigned task;

event, (task, CARD EVENT, s)

ro < ro

3 rt ifl y 3 rt \ n

-h H y

even ts-'int/cπt _e ven t . c

ttinclude "" '* event. h"

cr.t_ever.t (task,, s)

char -s-s? r V event (task, CNT_EVENT, s)

r <-r ι_'_. gyp

#iπclud "event, h "

onti- cl_event ( task.

L B K ;

event CONTROL_EVENT, s )

events/int/equeue_ιd. c

βϋtern unsigned equeue_ιd;

1 1* i-u L-ι|Lιf'L,e_

events/int/event.c

..in Li(J.

e..-.- er. t (tas. . sou ι_o , ...sci, _Lude ) urisigr.ed tasl „ source;

c, I Ci I I i t-'i |ι ie " ' i lr '

dr. valLie1 = nargs <) Z "' _cαde : ■" > dr . opcode — source.;

CDPV . SAFELY (dr , tr. nq_ daL , mr.g> ;

_ US*-

εvents/int/Qet event.

#iπclude " " event,h"

get_event (msg, status) i'oi * .'-- .-.._- ! _ unsigned *status;

extern request dr;

dr.opcode = BIVE_ME_EVENT; dr.string_data E 0 73 = '\0' * -

SEND (event_queue_id ' ) , 2_dr) r, strncpy (msg, dr_ string_data, sizeo- (dr.string_data) )

*ststu5 — dr.val isi. j return dr. opcode;

fvt_rιr-: mi ii.<_ιi::eτi i s

FLAiS

SOURCES = ic iies OBJECTS = ©objects

""""■" directory. $ (OBJECTS)

3 Cl y p

IP < α

ID

ID

3

3 0 rtl

• n

o

ID < I? 3

TJ rt Ifl I 'ifl

3 rt

T3

-Ψ+-2- events/int/pos_event. c

#iπclude " '"'event .h"

LI n s i g π e d t . char *s;

■•vent (task, POS EVENT, s)

events/in /puwer_event . c

ttinclude " * event, h"

p OWΓT _ £• v en t . t e s .

e/er.t > tc.s'. .. POWER EVENT, s )

event s/i nt/pri ce_event . c

ttinclude " '' event, h"

price_eveπt( task, s > un i q n ed t as k Ϊ

. i tr-.r

event ( task, PRICEJΞ ΕNT, s ) ;

..L+l+ -

ttinclude " event. "

* prιnt_event (tasl , s)

event (tasl , PRI T f ENT , s>

events/int/pump_event. c

ttinclude '" ' "eveπt.h"

ρu.τιp_event ( task, s, code ) i Las.. ;

int code? r

* u event ( task, PUMP_EVENT, s, code ) ;

events/int /show over . c

ttinclude "" ' "event . h"

s h o o v e r event sk >

event ( task, SHO _DVER, "" )

eveπts/int/stack event.c

# i n c 1 ud e " Λ event.h"

-,

ch, -K-S:

event (task, STftCK_EVENT, s) ;

events/i nt/start_queue. c

ttinclude "" ' ' event . h " s. h>

LI n _:' i q n __ d e q • Λ e ι. ■. e _ _ ... _ i ; ,

start_event_queue ( )

,r

equeue_..id = create ( 0, RUN_CONCURRENT , My_pr i or i ty ,

0 , 0 , EVEMT_QUEUE , 0 > ; return equeue_id;

_ i_

f f l+SO-

events/int/touch_event . c

ttinclude "''event, h"

touch_event ( task, s > i nt task ;

r

event ( task, SCREEN_TOUCHED , s );

-1+5.-

events/int /touch status. c

ttinclude " event. h'

char *s

event (tasl , TOUCH STATUS, s,

events/ int /vseek event.

ttinclude "'-event, h"

video_seek_event ( task ) int tasl;; t

event ( task, VIDEO_SEEK_EVENT, "VIDEO SEEK COMPLETE" )

— L χ .S3> -

ttinclude "vars.h" ttinclude stdjo.h

. U _ c n... t ,

sfcati uιi->ι uritt' ar εd , _.ιb . Lite , qr.-'frri bred, b b 11 ι „ h q r een '

draw _n_L arrow ()

er. r ^ .4. ire."

. ** -.-_ enL .J Ui /bar een

draw arrow (1 nt- ) un _ gned o I >ι—

i i| i i

draw reset arrow

write ϊ.nti v ι » l , ar ed , ..blue., aq. een)

- -S -

write_entry (i , r, q, b) unsigned 1, r, g, b; r

int templ ap;

_;.^ '-i:-' ; ri • ■ - '__ιBi t tr ι =-1"^ "" t i i".1 I HJI' _ ■'

S._-fcM__FL.r.cc_ an ' 1 i i ; ' *-- aeces≡ the input loo. up taoie (- * --

terr.pl"la'p = rnS-— nMap;

VWaitO; /* wait for vertical blanking «/

SetMSOutMap (mS- outMap] j /* select the desired map */

SetMSFunction (8) ;

Bt_tMbi|.d_; . ' ; •'-" St_-l-_r_-t ..ht. rt-. f tiπυ 1 n e

PUT_EMTRV '.targa- * ι obase÷MSWRITE, g) ;

SetriSIr.de . " - fc-et. l * _ ' r ■ ._*• i— _ •_' . _ .' ' H

PUT_E.iTF--vctA.u-Da-- tGba≡e+MSWRITE, b) ;

SetH' lr.Map t templiap .5 • ■- restore the original input map * .

read entrv t.ι, r b ) on 11

int terripMap ;

SetMSlnde.; (1 ) 5 /* Select tt.e starting mde,: »/

SetMSFunction ( 11 ) ; /* access the input lookup table <

tempt ap = rnS- inMapn

'v'iJrjη t ■ 1 ; ,' -_■ '- -'l t fι_ιr" vOrtlL.il t< l i'ifil r ι . ( λ

betflfi. Line ti or. (□) i

*r - GET_ENTRY(taι- ia- _ obase-i-MSREAϋ. ;

SetMS I nde.. d ) ; /* Select the starting inde!, *,

SetMSFunction (9) ;

*-g = GET..ENTRY ( targa- _ obase i-MSREAD) ;

Se t fid I n d . i . : • * *• *• Se 1 ec t 11".6- st _. i * t x r. <:_, mde, >

-K-b = GET_E TRY ( targa- i obass+MSREAU" 1 i;

/ * e o e tt.e c.πq r.al 3 ncut rr.ef. ? •■ '

___>* _' -.. i !.* I i f I i ι...l IUI ϊ- lL ϊ ) u

graph/c-fi les

display. arrows.

unpack_map»c pump DIM _ c

l-l * include "vars.h" + 1 ncl ud P istdio.h.-

d i _r J . i / \-r ame ( r >

ϊ cllllfe * + .

l -f ( ,-f = -F l nd_-f rame lr -- -string, data , 1 ) ) == NULL ) r

tfprintf (stderr, "DF " : can t find trame V.s\n" . r - stπng_d t ) ; e turn :,

pi u π i p _ c L c I.I r _ |T| a p :_ if.ao t - qr-F. t J ι I HI ra

|~' LliTiμ. __p.3 e L - 1 • f * > !i

el s pump_ * f ro. * ι._dι si (-f ) ;

υuniuJ ύ - , ' ιι.'i| . ' <" ' i Cj - i i -i __. ^ i v

Lir. i qrifc... i_|r fc_fc_π

int temp Map;

SetMSIndex (0) ; /* Select the starting index */

SetMSFunction ( 11) g /* access the inpLit lookup table (*/

vH lt l.' J f ~ Well .. τι_,| ¥s! _.1 ___Λ.L ι_! _. =ii 11-. ± i ly -■-•

SetMSOutMap (ιTιS->QLitMaρ) 5 /* select the desired map,

SetMBFunction (8) 5 putmap (targa->iobase * +-M3l'JRITE,CDL0UR_MAP_LENGTH, red) ;

SetMSInde;-! (0) ; /-* Select the starting inde;: Set MSFun ct i or. ( 9 > ?

— μ .U,__...111-. -P_ •.•--„ _-.c__ιr__ y_.___-- -.--.l , yr tit.-, i '. • „ _

SetMSInde;-; (0) 3 /-:c- Select the star-ting :L.-.de.=

SetM3Functioπ (10) n p t ap (targa- iobase+MSWRITE,COLQUR_MAP_LEMGTH- blu ) ;

'-se MS1r.ria ■. fiipπ'-i'-ip.' s . restore i ~ .e or_. ιna_. J.Γ.CC . , ~ -,

-M-S'

ttinclude 'Vars.h" ttinclude stdio.h

t v D e d ■? __ t r u c: t

-■r.-i i .

. _ ji .l__. unsigned tie 3 i . ' I C|h i _ font;

typede-f struct . char '=ιlue: l nt d„;

-n i t' l

, . „ ϋ , r I , _ • _, O , T η U -,

' M ' , V , 9 , 0 , N „ ό , 9 , U , 0 ' , 7 , , 0 ,

' F" , ό , '? , 0 , R ' , 6 , 9 , ϋ ,

( i ' ,

- oO-

W ' , 7. 9 , O , Λ . , - „ '•_'

' V ' 7 9 O Z', 7, 9, 0, " , "" , 4 , 9 , 0

~ ~ ~ 9 - /', 7, 9, 0, ' - ' *■ 6, 9, 0

<_ ' , 7, 9, 0, ' tt' , 7, 9, 0, ' .. ' , 7 , 9 , 0

1' , 4, 9, 0, 2' , ώ, 9, 0, ' 3', 6, 9, 0

4', 6, 9, O, t. ) , ό ' , 6 , 9 „ 0

6 , 9 , O ,

\c7) ' ϋ , * ..

bitmap a__Ua , /# credit due windows -for receipts -*.-/ aΞ'.Jb , a21 ,

cash_bits, ρrice_bits, eceιρt__bits.

Li Ti X fc. diO fc- U _Di l_ => , r ecjul r b its, su er_bits, saπsplmb , /* -French */ ordiπair, superspl 5

b i li.i .p

elS, el9;

bitmap insere, /* preset / deposit gizmos */ cashdept „ card «

-fill ,, p 1 e i n ,, ptrocard , vi sacard , ki osk , i osque , new nos .,

1 owbox ccfit't !

i n Toπ c.

DrI c font -ΠBWΠQS

draw_preset_l abel (language, amount) unsigned language, amount;

char cents C 5 71 ,

*c = cents;

copy_bitmap (?-lowbo:-:, lowboi- * . x_origin , lowboi- * . y_origin) ;

i-f ( amount * == 0 )

_.. — _. a. i ϊ Qfc.' - *. ' .!_.... -.'.. i ' _- , >. _. J. ^ coρy_bitmaρ (b. b — >x_αri gin , b — >y_αri gin } ;

tsprint (cents, " 04d", amount); i -F ( *c 1 = ' G ' ) draw char ( -s-c. _.acc toπt , i__ 3., = " ..

dr; ι_har .C++ , " _-c_.i-.i-. tOii r ciϊ._ι_ι.δr '.«-!_++, .-:(_IL..-_TUΠ _ . •-.__.'•-'■ ■-• / draw char (*c, _.acc tor. . 33'~',, 3^

i-w .a.u uπt) unsigned amount;

char cents L 5 71 n

-.-q_b2>-

copy_bit ap < ..topbox , topbox . x_σrigin , topbox . y_origir.) 5

tsprint-f (cents, "7.G4d", amount) 5 i-f ( *c i = '0 ' ) dra _char (*c, S.acc_-font, 273, 43);

C++;

■ir- ci". ■-• -" ■■ >" ''■'.". ■■ ■■ -•- -i , :•- ,"." draw_c:ha'" (*c++, _.acc__ ont „ 32 ,, 43); dr _char (*c, §.acc_-fσnt, 339, 43) ;

draw__clear_prepay ()

cc.py_bitiT.ap - ..accrset, accrset. x origir. , accrεet. γ_origin) ;

LInsigned type;

bitmap

ι_ se ' _. ; b •".. v 1 __> a ι_ a r _.! ; b r f a k ; case 1 : b -.ptrocard; break; case 2s b 8. tr. s t r e a r d ; b r e a k ; de-fault: b 0 ~ h e a k :

it (b) copy_bitmap (b, b — >x_σrigiπ , b ->y_origin>

draw_transaction_type (language, type) unsigned language, type;

*._ιrt_!i_ι.'rι — i i..u t-sye V ': < inst.re _ 5.ι_a_-.bdt__ρt ? *hole = l nguage ? S.kiosque _ ξ.kiosk; bitmap -x-btype;

switch '(type) r

sθ is uv e — CJΓSBΠ; reskj πS ϋ? D * t D5 — icisii π bfeakj dst 3.L1I ii u ut θ = πoie j rstskj

copy_bitmaρ (btype, btype ->κ_Drigin , btype ->y_origin) ;

di _...J__:.tfl t.ι_tι_-d-_yr __dι_- language) unsigned value, language] r

bitmap *b = 0;

switch (value)

- - -O5-

case 1_ b = lanquag". ? ..o dinair s ..regular_ bits? b ea case 2. b * = language ? ..sansplmb : S.unleaded_bi s; break case 3: b = language ? S.superspl : 2.super_bits; break •>.

i-f (b != 0) copy_bitπ.ap (b , b —>x_ rigin , b ->y_origin) ;

draw_pu p_number ( numb r ) unsiqned nu ber;

i-f ( number > 9 ) number = 9; draw_char ( number + '0' , S.cash_in_-font , 359, 92 )

I'.'" w_c sh_iri (c nts ) unsigned cents;

unsiqned digit;

digi = cents / 10; i-f- ( digit ! = 0 ) draw_.char (digit + '0' , 2<caεh_i n_-f ont , 41, 172) ; digit • = cents 7. 10; draw har (diqit + '0' , &cash_ in -f cir.t , 83, 172) ;

draw_prices (regular, unleaded, super) unsigned regular, unleaded, super;

draw_price (regular 130) d r a w_ρ rice (Liπle ad ed , ^■=;" □=; • _-_-,..—-. I —/r. -; c_r s-_ nr - ~i _, ~* ό .- )

draw_ρrice .ρrice_ir.__teπtns, κl, y, ;-;2) unsigned ρrice_in_tenths, .1 , y, x2;

char cents C 4 1 ,

*c = cents;

__-pr ιn_. * r \i_t_-i ιx=- , .-»_'-__u , p.11_ ι___ι π_ _.t__n _.πs. ; draw_cπar (-*c++, s.ρrιce_-f ont ,, x 1 , y) ; draw_char (*c++, ?φrice_+ " ont , x 1 + pri ce_ ont _ -f width , y> ; draw_char <*c„ ..price -font , .-.2, y) ;

d w_cr ed it ( cr di t - Ian guag e >

. EΠSI gπe__ credit, ianguaαeϊ

bitmap *bl = langLiage ? S.a21a

*b2 ~ = language ? S.a21b : J_.a20b; unsi an ed dollars — credit / 100.

— q-bl-

l f ( credit - 0 )

coρy_bitmap (bl, bl - x_orIglr. , bl - y_oπgin); coρy_bιtmap (b2, b2 - ϋ_or]qιn, b2 - y_oπqιn>

'ji"_ '". i ' • ι-j i L _ιr_- L'_ - < draw_chαr (dollars "„ \ 'J + ' ()-> .sr.. dr w_chc * ιr * (cents / ! '' t '' ) , draw_char (cents 7. JO + 'υ' , f , 151 , 285) ;

dr w cβr. t_i ( credit , L -j.niu qe in ..< i q 11 j ici

bitmap fc-b 1 = 1 nguage e 1 ,

.. i I " ..-..-..! _> L U'l j U I

L Op Y _ U . LIU <-.{_■ \ ... , or j ci 311 , b ' - s or \ ci 111 ) / K * go to . IO I */

drε.w svsl- * ?... cancel u'tT' it , 1 a - ιaηp. >

dpi-. -- -t- 1 el ci _ce tr _.-. - __■'.-'.. i .. IG _O-V- -f-set ; draw_string ( _.receiρt_bi ts, receipt_cel Is , s, dp:-: , y, 7 ) ;

εtri ng_ρi;-;el_length (sc, s, blank_d;;) cell *SC!

*c; int pixel _length = 0;

•for ( ; *s; s++ )

find char,; s) 3

; e .1.

r e t LI r n p i .-; e 1 _ 1 e n g t h :

bitmap *b; cell *sc; char *s; int oκ, oy, bl nk_d>.; r

cell *+iπd chars cell () ,

int bp " : c>y; / * initialise the drawing point *

for ( *s; ++ )

i-F ( * s ==. ' ') dpx += blaπ ' k_dκ: else

c = ind_cha _cel 1 (sc. *B) ; copy_char (b, c, dpx , dpy) ; dp-x +-= c —>dκ;

cell * ind_chars_cell (c, achar) cell *c; char achar;

- -11-

for ( ; r --value i = '\0 ' ; r+i- ) if ( r -.value == achar ) return r;

returr. c;

co y_ ct.cir ( , c, ,, , y) b_ tmap *b ; eel 1 *-c ; r _ unsigned offset,

L .

ι_. ι -i __ .". μ — c. - ".. T i <_: .__• r I for ( i = 0; l c - dv' l ++ >

iTiov - " tes (b — Ξfg.t.er.L

L. J C _ '-I '_'. ' '. I.' .'I ' _l ' -i 1 1 r. „ of set -i = L. - r ri

draw char (c, f y>

:h-_ι,

font # ; int κ , y; r

unsigned offset, i j bitmap *b = -f -7> ontbits;

for ( i = Of i <7 ~. ': fheight; i++ ) r "u movebytes (b —>seg> * nent, offset, my_ds() , work_buf , f —>f idth) blastrow (work_buf, x, x + f —>f idth — 1, y + i); offset += b —>row_l ngth;

:oρy_bitmap (b, x, y) bitmap *b; int , y;

u signed l_ΪV T-I-.L

for ( >nrows; i÷+ )

movebytes (b ->segment, offset, rny_ds() , work_bLtf, b —>row length.

J 1 r !_- e i. +-- U - row_ier.gth!

typedef struc ϊ.

b ap L.maps C 3

i_"C_-.sh__bι ts , "depno" , ?.pπ ce_b. ts. "qradenα" , S-un. eaded_ bits "un ead" ,

•_'i __ |LIJ -. (" _lι_ ι. : , qui

?. __' ,r_.f--r n i t -Z "ii'per", ". ansir-J .fi , '' -=ar.sμl mb " , ϋ'ϋr inai r , "ord_ r.ai r " , . su erspJ , "sLiperspl " ,

' " i ... ,

- 3 _. "• ' " < b , .ι_. _'L. ,,

ts. 'rctlettr"

S*el , "eJ2"

1 " "

S.ei-?, ;1 -J

• insere, insere

..cashdept , "cashdept",. ϊ-card , ,r card", ?.carte, "carte", ..fill, "fill",

1 ._ Ϊ i r. ,,

■ϊ. p ._ o c a r , p L|- OI_.__.1- d , ■__v i sac ar d , "visacard" , S.iTistrcard , ".Tistrcard" , S.kiosk, "kiosk" , 5.kiαsqLie, "kiosque", S.n e wnos , "newπoε" , S.topbαx , :αρbαx 8.1 owbox , 1 uwbo "

ini ti al ize_bi t.T.aps ()

b.T.aps I

for ( i = 0; i < sizeof (b aps) sizeof (fa ap) ; i++, b++ ) store_bitmaρ (b — >amap, b — >file) ;

coιTιpute_receiρt_of f sets () ;

store_bιtmaρ (map, name) bitmap *map; char *r.ame; r

L.r.siqned oft set,

<__■[ ιp_l e-f t = 0, s. . p__rιgh t •= ':• ,

J . ; FILE *f; struct hd&t.-Lict h.

i, " : Getr-'i cl-leadcr ir.a.i.c „ ..-, , ~\ or 1 _c.uf ) ~ ~- -L ) return 0;

if ( strcmp i name, "depno" ) == 0 )

sl i _: row — 1

ilse ι. ( strcmp (name 'qradeno") == 0 )

s. ιp_l ef t - 1;

h.x — = choρ_x; h.y -= 1;

else if ( strcmp (name, "rctlettr") == 0 ) r

skip_left = 5;

εkiρ_row = 17; choρ_x = 7;

.. ; ; — L.1 ιOp_X h.y -= 21; /* 4 on top, 17 off bottom */

el se i-f C strcmp (name , "ne nos" ) == 0 >

skip_lεft = 1; / & 1 or. left */ h.x -= choρ_x;

al 1L.ι___tι___bit_=, ...dp , h_ Xuffset , h. VOffset , h. x , h,. y) w offset = map —>offset;

for ( i = 0; i < skiρ_row; i++) fget (work_buf, h.x + chop_ , f) ;

for ( = ; j sl- ιρ_left; j++ > getc (f); get (wor)-_buf, h.x, f); movebytes (my_dε(), work_buf , map -/segment, offset, h . tt ) ; for ( j = ; j st- 3 p__r 3 qht 5 j++) getc ( f > ;

return 1 ;

al 1 ocate_bι ts (b, ox, oy, d,, , dy) bitmap *b; unsigned ON, Oy , d„ , dy;

_r _ π ι nrows all θι_ ram ( d r.b - S 'LI erit , S-b offset ; b - r DM 1 is no t I i -- u <

COnipLt LI_ I r-r i ϊ . I 1 Sl- .. - '

cell -t-r = recei ρt_cel 1 s + 1, *p = receip _cel 1 ; int sum = 0;

--HE- ii -.It- * . r++ :■++ .

sum += p ->dx; r — >off et = sum;

-i-yfϊ-

q r ap h / * . i n d __-f r aπ.e . c

ttinclude "vars.h" ttinclude stdio.h

rr_ι.ι.ρ t-i u rame ' ( n ,, search r|ι = r /

int ≤earch_d. s ;

frame * ;

τor , -1 ~ t ι r - , _ ι i af.ι__.. "> ", -! ; * = e ;t r-a.. ' i--' ' L { . -t.-c.np ( n, f - r.Λ.r.t_ > --- >

■' - net n RAM, mεivbe on d. l " ■ •* *-.'

ι T i. seorr h_dι s. J

_ f r aπ.e , -, r _r t c h ι.ιr 11- - MU L L -, COP V_ SAFELY.; name_bu * . , n ' _ rame. name = name _buf ; return •* frame;

-WO-

graph/globals. c

ttdefine GBLGEN ttinclude "vars.h"

— \-

graph/graph. c

ttinclLide "vars.h"

MOSt r ne in J < _.τ.2;

typedef struct C

TARBtruct *tt;

MBStruct #mm * 7. targa_board;

!i-dt-_---ι e NBUARD3 2

tarαa GOS.TI Larqas fit. C->A 'PS 71

tl ,

d, li _:ll If" int argc; char -K-argvCl;

request r;

j i i i i. i ' .' _ L - i ' a i L! . , ..I i i a . i. J i „ <_ι r c

-ψδl-

r ( ; ; )

client = RECEIVE_ANY (S.r) ; if ( select_board (r.valuel) = * = 1) switch r. opcode )

case LDAD_FRAME: _load_frame (S.r) ; break; case DISPLAY_FRAMEs _display_ rame (..r); break; case CASH_IN: _display_cash_in (S-r); break; case ALL_PRICES: _display_prlces (_.r) ; break; case QPEN_SCREEN_ _open_screen (r.valuel); break; case CREDIT: _display_credit (S.r) ; break; case GRADE:. _display_grade (?.r) ; break; case PRESET: _display_preset (_.r); break; case RAI _USAGEϊ ram_usage (); break; case DRAW_STRING_ _display_string (_.r) ; break; case DRAW_CENTRED: _display_ceπtred C_.r> break; case CAMCEL_CREDITs _di_.play_car.csl (S.r> break; case NEXT_ARROW: _disρl y_neκt_arrow(?.r) ; break; case RESET_ARRDWs _display_reset_arrow () ; break; case ΪNIT_ARRQW_ _displ y_init_arrow () ; break; case PRESET_LABEL: _display_preset_label (_.r); brea case TTYPE: _display_tran_type (§.r) ; break case CARD TYPE: _display_card_type (!_.r); break

Ca~t. M H _ i ■' ι_L_ii*l ! diSpiriy Cash ' .i Pi i *_.;■»-■ ■ • V • . . ,.-IΆ-,', -ι5t L-LLrt! "' _ 5 _di spl ay , _ci ear prepfiv i i , Pr sk

case L_QAD_BITB- _di spl ay_l oad_bi ts () ; brea case OPEN_SCREEN_WARt v l: _open_screen_warm ( ) ; brea case SYSTEM_CANCEI__ _dιspl ay_system_cancel (S.r ) ; bre case DRAW_PUMF : '_NO_ _dι spl ay_pu. * iιp_πu.Tιber (2-r ) ; bre

l- __ • ._ i ' . , i i? . i ' - ' i

Initialize (c, directory, map-file, base_selector)

char -K-directory, -f ap ile, «-base_5elector; r

unsigned selscti-_.r__.ase;

i-f .c '=• 3 ..... c '•= s

ttprintt (stderr,

"graph qrΛ!.-.- L"5_CII rector ..i-Λp-f T. 1 e .•] set or\n" ) e-; i t ,ι " '. s

sel ector _baso = Lc.l ι 'baSF_5&i ector , ;

i-f < regιεter_naπιe .υ, &RAPHICS_NAI E , 0) ) abort ( "graph, cs tasl- can't register") ;

cl 111 J I lϋ. -... '.i 'I ' 1 I I i ! i L-I I L , . . i . '

AS-+ -

frame_top = NULL;

_t1. iobase = Oκ220;

_tl„memloc = selector_base; _tl_srcsel = sei5ctor_base +- 8;

_ 2. fne.Tiloc = selector_base -• - 16; _t2..srcsel = selector__base +- 24;

1oad_colour_maρ (map-file);

oad_colour_map (map-fi1e) ch ar *.τ.aρfile

1ι_E * s- ;

i-f ( (- = - open (map-file, "r"> ) * == MULL )

exir

- qet (work_bu-f , si__eo-f ( ork_bu-f) , -f ) ; unpack_maρ ( work_bu-F , red_maρ, green_map , blue_map) ; close (f) ;

dregister_name ( 0, GRAPHICS_NAME, , ?...unk, .-junk ); exit ( 0 ) ;

n—; i-f ( n 0 11 r. =• NBDARDS ) r •_. t-fpπntt .stderr, "invalid targa "Λd se_ected\n", n + 1 ) returr. 0;

t a a-- q _-. " l 1 11 u _ ■ - L i , i , 1 1 ii returr. 1 ,

-^b-

graph/graph. h

ttinclude "/user/steve/dave/dave_request. h"

RA

#C def i l i lt- I Ϊ Rϋi. ii 512

ttdefine FRAME NAME 3υ

ttdefine CDLOUR MAP LENGTH * bytes */

/* requests */

4

10 11 12 13 14 i- **7 .

ttdefino IN1T_ ARROW 17 ttdefir.e CARD_TYPE 18 ttdefir.e CABH_I _LOW 19 ttdefine CLEAR_PREPAY 20 «• .--t i n ..'PR' , WARN

H ■_._. I J. i i _ _ι i -■ i ι_i I L i ii-JL c ι__

.. d r . r. e DRAW _ PUriP_MO 24

ttde ir.e GRAPH _C'_-._NAME "graphic * --" ■'-■-- for regi £ tr at L or. ~ ■'

typedef struct _chun. C unsi gned segment ;

. un *" I gned __ .- f set ; I r. __ 1 ϋ n e ι.l

J c un. r,

,__ r, ._ i j (__ { = t r" L I L- I" C

11 π r> i c ■ n i? .:i '_. r f __< e t .

..n-_ . q i.-'ύ r m * L s.. i >Q ι I . - unsi gned nrows ; unsigned -,_orιgιr.i unsigned y_or gin . J b i 1 rn ~ι . ",

-WS-

int left; int bottom; int right; int top; J* bbOK;

t-'-jjedt't SirU ' - _ + r-_iiiiS har *name; '* screen name */ bboκ b; unsi gned has_rnaρ ; chat- *red_rnap; char -*qreeri_map ; •_. i-_.ι- *__-iue_ιϊia ; hunk -S-f i r __t - UI . k 5 ft cunt;;

typedef struct u.πsiq πed ι_ι ici'r ed

map_ι_l tr y J

grap /graph. ap

.Segments 1 OOOO to 3F1B (_έ>156 bytes) .Segmen : 2 OOOO to 02FF (76S bytes) .Segment : 3 O --0 to H C .' Ξ97 bvtes.

C I.IJ u0' ., prol•_■ .._i_;

CO U05E epilogue

CO1 OOά7 s11 _o-er11c*.

COl 007D e,.ιt

COl 00S3 lucbeq

COl 0084 _dιspla»_τrame

CO! 0106 DUiii _co I o' r __mc.p=*

Co L 0 B mam — ' 1 J _!• i-i- I I > Λ t _ J. ] 1 - '-"

1 c ιd_ col our _ m e 1 ec _. _ _ ■ o _? f d i-.,. - -, .,

-.lr a^. cifT n ;j , - - 1,_ _ , .-__., -; ci r r o (• * wπ te___n Cr y re so entrv dr a _prese _1 αel

-W)-

Ol 0919 7draw_transactiαn_type; O1 09A3 :draw_selected_grade> O1 0A24 7dr aw_puiτ * *p_number > l 0A52 ;draw_cash_in > Ol O CE .draw_ρr i ces

<draw_cancel >

'.draw system_cancei >

<dr w_receiρt_string> <draw_receipt_cer.tred7 <string_piκel_1eπqtπ> draw_string>

< f i π d _ c h ar s _ c s 11 >

< d r a _ch ar >

-■ ' -. c o p y _ b i t rn a p

- : . i n itia.l_.__e bi a p s > i_.l_.r fc. U bii __μ .•- '--' ... i. __.r-l ^

. ι_ι_nιιμU.tt_._f t.ι_t. J. p ___.-i--r__.et':

:-find_fram_.> 7_1 oad_f raιτ.e> !load_f ail > >. Dad * . i ~

- rt;,.-'. v" t ' ^.,1'ι t -

-I+T.-

COl 1621 set_col our_maps

COl 16DC load_ρι.:el s

CO 1771 .al ioc_chun.

COi J__4 L liii. chun. i. i , : -V " t I i- -., I i _..-|ifc *

CO 1 J 3_j_. In. 1 . _ r r me COl 1SFF y + ree.

COl 191 pump_f roιTι_clιs. CO 1 19 A A l r. i 11 a 1 i _z o_r am al loc _raιr. r r. i _ r e n . a ". i * .3 r. o t~ -.•.... _ UsriOS i lι-._ ' i . _QD&ri__.."i een Ol _OD en _ ser een _w<_ιr C l 1 f-o_.t _ dj _.•--.. J a «_c;ι? in _7' ' i j 1 " . j ι - . - m 11 iin .'.-.iisi- cj i _r . J a _ t ii R

_ l s ] a , _ρr ese t _dι spl y_credι t _dι spl a '_.__ancel _rlι <r -μ>l ι- ^ _ =>. , <= heτι_ c^nce 1

- - -

<_di splay_rB5et_arrαw> <_di spl ay_ne.ct_arrow> <_di spl y_i ni t_arro > <_di play_ρreset_label. ' < __d i p 1 ay_tr an_tyρe >

Ol 20D5 <_disp1ay_casl * ι Ol 20ED <_display_clear_ρreρay: Oi 20FA <_disp1ay_1oad_bit > Ol 2107 <unρack_map> Ol 21ώB <purnp_pixe1s> Ol 2196. < b 1 as t _f r ame > Ol 226B <show_-f rame_by_rows> Ol 22D0 < p ump_ch un k > U1 <-f ui 1 _wi dth_-f ra.τιe> oi < l astro vι> Ol 23C6 < movebytes > Oi 23EA < moved a > i 4GE tr. - : ..Try u.

:SetE>estBan : Oi 25A2 !SetBenLock> O1 25E5 :SetSrcBank> Ol 2631 " .BetOverscan ' . "^etH ' βorder "' -

-. i . _.n ..-:-r

r3 r.l

,-t

- i °[- -

C i 3 " 70 ύ coi 3772 oi 3 18 coi 3932

coi 39ES coi tt.__ά

C'J}

coi ->H|-tC-

tr

IJI i r. Ϊ

COi 3C0 iepijcque COi 32].' Imui

C'JJ _ιl_r_. I J ...l-' l . Ol L o i r COi 3C79 ldiv Ol 3D32 vc_send_re l v COl 3D38 vc__create

Mb-

COl 3D50 <de*f_server>

COl 3D56 <set_acc_*f 1 ags.

COl 3DΞC <SBt_e>:ceptioπ;

COi 3D62 <escape_tty>

COl 3DώS <hold>

I I .. I I

DOO 0025 <l y_priority>

DOO 0026 <stdiπ>

DOO 0028 <stdout>

DOO 002A <stderr>

DOO 002C -(Free iist>

- •.C_!tι_- '-_

DOO 0O30 <Fi1e_iist

DOO 0032 _Argc>

DOO 0034 <_Argv>

D00 0034 εtk_limit

DOO 003o SAVE

DOO 0033 TEMP

DOO 0060 <Code_ 1ags>

DOO 0061 <ύser_nuιτι.>

DOO 0062 <Gro' ρ_nuιτ. _ *•

DOO 0063 <Tea.τ._n tιTι>

DOO 0065 <My_nid>

DOO 0067 <Bads_nid>

DOO 0069 <My_tty_nid>

DOO 006B <S'iy_cd_nid>

DOO 006D <Rel ease_rι iιTι >

DOO 006E <Ndp_save_area>

DOO 0070 <Fstack>

DOO 0072 <Call_stack_ptr>

DOO 0074 Seαment_tab I e ntr

DO'. ' i 007.! < > _ '■_-1 __poιπ; . _sρ " '

- tt-

-5θ° "

D03 OCOS <supe spl>

D03 0 14 <el2>

D03 0C20 el3>

D03 0C2C <el8>

D03 0C38 <el9>

D03 0C44 '•.iπsere _■•-

D03 0C50 <cas dept>

D03 0C5C <card>

DOS 0C6S < arte>

D03 0C74 *fill

D03 OCBO <plein>

D03 OCSC <ptrocard>

D03 0C9S <vi acard>

D03 OCA4 -(mstrcard)-

D03 OCBO <kiosk>

D03 OCBC <kiosque>

D03 OCCB <newnos!>

D03 0CD4 <topbox>

D03 OCEO <lOWbOK>

D03 OCEC < ccrset>

D03 0CF8 <cash_in_fon :

D03 OCFE <price_ oπt>

D03 0D04 acc_-font>

D03 ODOA <bmaps>

D03 ODBF <free list>

i aρl . / 1 oαrj -t " i c< > 11 e-- _ c

ttinclude : .stdio.h> ttinclude "vars.h" ttinclude < se j mp . h >

static j.T.p_bu-f 1 oad__trap ; sla s t ,- •.-.i.i?' t*-f r ■! static FILE *dι .

ttde-fine NO_SEBMENT

_load_ rame <r) request *r $ r

int. code;

if (code = set jmp il oad_trap) ) load_-fail tr, code); el se

load -fail it- code) request *r; int code;

-SCO--

free_ rame (fr) ; if (di ! **** NULL) close (di) ;

loadit (r) request *rn

long r m_remaining (), ram; struct hdStruct th;

ram = ram_remaining ();

if ( find_frame (r ->string_data, 0) i= NULL )

/* frame already in ram? */ longjmp (load_traρ, 1);

if ((fr=(frame *>callo (i, sizeof ( rame) ) ) = ** = NULL) longjmp (load_traρ, 2);

if ( (fr —. * -name * = (char &) calloc (1 , strlen (r->string_data) + D) =-= NULL) longjmp (load_traρ, -5) ;

strcpy(fr—>name, r—>string_data) ;

if ( GetPicHeader (fr ->name, _.di , S.th, work_buf) == longjmp (load_trap, 4);

SUBSTITUTE SHEET

I f L_' II I Is. - . — . i ■ Λ.Jl I . '-' t ; fr --b. bottom = th.YOf set; fr -.b. right = th.XOffset + th..! - 1; fr -.-b.top == th.YOffset + th.y - lϋ fr -.-has_map = th. apLength * 0;

i ( set _co lour _ιτt on (di , f r ) * == o )

1 in. _ rame (fr);

r - ' val ue 1 = 0; close (di ) ; tfprintf ( sl-derr, "use ".Id rern r*!.. - rftiii_reιrιS] ninq . > , rafiι_rern<=ι L .". _ nc

rame * ;

cn ιLιrr.u1

gtree .-f - gr&en_nia&) ; gfree (f - blue_map); gf ree .f - name) r;

r •-■! ' . i i ϊ " -- ' I ' ϊ. i i -1 L

SUBSTITUTE SHEET

-6C --

t =- c — >neκt_chunk; gf ee (c) ; c = ts

g ree ( ) ;

1 our _ a s (filt*, / g r */ FILE *file; frame * ;

char *calloc ()

i ( f — >has_maρ == 0 ) return 1;

t -r-uiUt._i.i-ip — CdiiuLii , __._J__.i L. p. _r.ι-.r __-_.-_.hii_. ! n .' ; f ->green_.τιap = ealloc (1, CQLOUR_MAP_LENGTH) ; f ->red_map = callocd, COLOUR_MAP_LEMGTH) ;

f ( f ->blu.e_.τ.ap == NULL 1 ! f ->green__map == NULL ! 1 f — >red_maρ = * " * = NULL r turn U;

fget (work_buf, 3 * CGLOURJ*1APJ_ENGTH , file); unpack_map (work_buf, f ->red_map , f -7>greer._. * nap , f - >b 1 LI e _ ap -) return 1 \

_5θ5-

load_pι.ιelε (file, f> FILE *fιle; frame * ; r chun. -K-CII l DC. chun. O _ **-cq

I ' 1 _ '.._. _ _ 1 f ll . - I . ' 1 i - 3 * . — 1

13 nes = f ~- b.top — , — b.boLtoni + 1

] iι"u?_≤_ le = ** f - b. right - f - b.l ft + 1 ;

1 ιπeε_ρer_chun. = CHUN. _3IZE lιne sι_:e;

while ( lines ) r _

1 -- lir.es j ir.es _ρer _c ur.l " iir.c-.--._per_chi.in

1 i rn ** ?! c - _ J or _chuπl .J L L r_ _ ___. ' load_lιnes (file, 1 „ 1 ιne_sι __ε , c); 33 nl _chun. (f , c ) ; 1 e ** . -= 1 ;

chun. κallDC_chun. .r.bytes) unsigned bvtes;

' I t I i l.

if ( (c = calloc (1, sizeof (chunk))) == NULL) longjmp (load_trap, NO_CHUNK_DESCRIPTOR) ;

if ( alloc_ram (CHUNK_SIZE, & ->segment,

?.c ->of set) == NULL) 1ongjrnp (1oad_.trap , N0_SEGMENT> %

return c;

load_lines (file, count, line_size, c) FILE *file; int count, line_size; chunk *c;

char *pJ unsigned i , j ;

set_eκtra_segment (c —>seqmeπt) ;

or ( i = 0; i < count; i+÷ )

get (work_bu ., liπe_size, file); /* read a line */ for ( j = 0; j < liπe_size; j++ ) /* copy it to the chunk **.

(_.p++ = work_buf C j 735

c -.'ii ie ouπt = counts

-SOI-

li _chunk (f, c> frame *f; chunk *c;

*L.C !

if ( (cc = •> iι-st chunk) == MULL)

>firεt chunk = ci el se

for ( ; cc; cc = cc ->neκt_chunk ) p = C' p -->ne..t . chunk **** c;

frame -s- irst frame ( )

r turn trame_top

' fra e *ne.;t_frane (f ) frame *f; r

return f ->next frame;

soS- liπk_frame (f) frame * ;

frame *p, *c;

for (p = c = first_frame ( ); c; c = ne:.t_*frame (c)) p = c;

if (p == NULL) frame_top = f; else p - ne't_ rame = * f;

qfree (c) char *c;

if (c -=-= NULL) return; ree (c) Ϊ

•ttinclude " /user /st eve/ t r g a/ tarde v. "

MS_Ir.ιt (t, )

T St met -st.

int bottom, top;

t-.-boardType = TYPE_M8; /* always an MS * / t-. /O set * = 0; t- /Offset = Oϊ /* default to no offset t- L_ πesP&rFiei ~ DEF_R0. l .S/'__; .' * number <- ■ f l ine * , par f. t- Al a sGenLoc. = 0;

L- F-aqeMode — 0_ t- ' interlaceMode = DEF_INT? < " * De aults Ent.rlace Mode

L- ^Contrast = DEF_C0NTRAS7 ; t- Saturation = DEF_ S rURATIOM? -- i-i e - ULI- _. ιuι__i r- RGt-io C 1 ^' — L'v\ ' =•' de-! atil t to LORΓ ._..>-- . ! f_ « i e >- t- VCRo ame - CAMERA; t-'-Par.XOrig = 0; t- PanYOrig = 0; t- --PageUpper = O.tffff ; / * set the ban. -t lags to ill t- PaqeLoi-ier — .- -f÷f j 'A- values so th.it th -._.1 ] ....

.- ' * the first time t->ovrscnAvail •= 0; /* Assume no Overscan option *

/* Set defaults for the M8 TARStructure */

m->there = 1;

.τ.->ir.Offset . = DEF_MQOFFSET;

-n-->in6ain = ** DEF. MSGAI ? ->iπMap = DEF_M8ΪNMAP; m->outl ¥ iap = DEF_MSOUTMAP;

.τ.->ir.putMu * ι = DEF_M8MUX; m—>loo Thru = 0; ιτι->mod©Register = DEF_M8M0DE; m->CGAInterl ce = DEF_CG INTERLACE;

t—>ovrscnOn = t-*>αvrsenA ai 1 ; ra->t ere — 1; t->MaxBanks = S; t->BytesPerPi.- * el = 1;

t->RowsParBaπk * = * 64; t — >HQ-ire≥5Shif t = 0; / * iiσ \ ~ \Α≡ __:• , " ddftSS Shif

SetSaturatio .t->Saturati on) ;

/* if initialising CVA, set * SetHue (t— >HLie) ; /* these befroe we quit *

SetContrast ( t— .--Contrast) ;

* Sf'-. eπiijά. ...it it , -. !■- * .-.- - -. --

/ r =M.ι b f - 1 i fc fl_.f pir.iq .. r ι • ■* i te.. i r.q sr i •?< n ) -/

SetMαde< <t- -Al aysGenLoc - SHF_GENLOC. > i DEF_MODE) ;

SetBlndReg(O) ; /* disable blend mode on TARGA 32 */ /* internal logic - SetBlπdReg */ /* ma. es this a no op for xhe „ MC , lo, and 74 -/

oetF r.edReqi t rs ( ) ; / f- όet Fi _--d DispLa-- Regi _.te-r__ -" * - SetOverscar. 'Jr- ovrscnOn ) ; /->'- Compute X border .

top = 140 - <t- LiπesFerField 4);

/ * Set Vertical Border * / bottom » toptt-"LinesPerField

f Ensure that YDffset does not blow is OLIL of the screen—

. .._ T , . n (.unbcjr of j _ n ^ j __ _. -jci ' j t_ι_ _.. . a if rnq c

_ /

if t- vOt set 0

_ i i t ~ — r . i . fc L ' i I i I' I i -'

t - v- 0 T t - M L I . _ U ! - to ; top = MIN .0P;

bottom -= t — vO-f set?

r

if ( (bottom - *** = t->yOf set> > MAX_B0TT0M ) -C t->yOffset = MAX_B0TT0M-bottom; bottom = MAX_B0TT0M;

*

SetVBorder(top,bottom) ;

SetVCRorGamera(t->VCRorCamera) ; /* set MS vars -*/

SetMSO-f-fset (m->inO*f-Fset) ;

SetMSBain (m—>inGain ;

SetMSϊnMap (rn—>inMap) ;

SetM80utMap (m->out! ap) ;

Se MSM K (m—>iπρu.tMuκ) ;

SetMask (DEF_MAS ) ; /# Set other Control Registers

SetRBBorCV (t->RGBorCV ) ;

SetVCRorCamera ( ->'v'CRorCamera5 ;

SetVertShi-ft(256-t- LinesPerField) ;

it ( VtøaitO -= -1> -

/* is raster reqister is workinq correct retLtrn (—1); /* no —return error flag */ else return (0) ; /* everythinα's ok */

SUBSTITUTE SHEET

ttdefine FI ED_REGS 10 static int FiκedRegsC 3=

CDR6,DR7,DR12,DR13,DR14,DR15,DR16,DR17,DR1S,DR19 ; static int FixedValueC 3= f DC-7F_ DRώ , DEF_ DR7 , DEF OR 12 , DEF DP 1 , DEF _DR 14 - >l-lr _ i ' i 'ZJ A ϋtl~_L'iΛ . _• M l- .l .El . . , _)l" '" __UH j. w , L.u.. _ _ ,' ,_ ' •_ „

* SetFi tedRegisters <)

* Set the registers which have required values */ static SetFι .edRegisters ( ) r

lr.. rsg;

for ( reg=05 reg F1XED_REGS:; regtt)

SetDi pReg (Fi, ted Reg 17 reg 3 , Fi>cedValu l7reg3 ) n return;

graph/makefi1e

CFLAGS = -S +Wc,+u SOURCES - ©cfiles OBJECTS = ©objects

graph. *(OBJECTS) linkobj c=graph κ=objects 5=2000 =graph.map l=/user/steve/dave 1=/user/steve/tar sort graph.map f=l,2 +r copy graph /dave/graph

-tiobals. o_ vars.h

-SiS " -

graph/memory. c

#in lude ϊtdi o. h 7

#de ιne NUM.,PΪECES <-?<_.

,. --fιrr PIE E __J_Ε 4'.'-

t I __ __- 1 - li -, i __•-!

typedef strLict £ unsigned selector;

Linsigned offset; long size; 3 piece;

piece free_lι t E MUM_PIECES 3;

r _ piece *f = free_l3st; int 3 = NUM.. PIECES;

or . T 1 ; 1 — , -i-t

f - selector = al 1 oc_seg en t ,PIECE_SIZE) ; f -.offset ~ 0;

ii 1 oc_r arri .n yt__s, =.*__! t__-tQr" , t_ * r -__t. t > unsigned nbytes, *selector, -x-offset;

piece *f = free_list; int i = NUM_PIECES;

if . (nbytes 7. 2) == 1 ) nbytes+tj

for < ; i; i—, ++ ) if ( f ->siΞe > * = nbytes ) r

f ->size —= nbytes; ^selector * = f ->sel ctor; -s-of et = t — of set; f ->of set += *** nbytes;

return s

lung raπ"ι_rt-.ti__.i.ii.tQ '.)

piece *f = free_list; long remaining = OL; int i = NUM_PIECES;

for ' 5 i ! i— „ f++ )

e-ifiBj tun ' - f — _XZ .a "

return remaining;

ram Ltsaqe ()

P3 i r S-r- a

long rar.i_rerr.ai rii nq . );

For . rows = 0; rows NUM_PIECES / S; rowstt ) r

for ( l = 0; l 8; ι++, f+t ) tfprintf (s c-err, '"..i-ld ", f- -- _-.._.e> i t printf i stder . " \n " ) ;

tfprintf .stderr, " \nrer * "/.ld\n", ram_reπ.aιnιng )

SUBSTITUTE SHEET

- < 5\2-

graph /objects

display. α globals. o graph . o ar r ows » o draw. o f i πd_f ra e . o load_f rame.o puι * np_dis - o memory. b m8init. o ser vi ce dav „ o unpac map . o pu ρ_ρi K . o

f €\-\-

graρh/pump_d sk.c

ttinclude "vars.h"

#include stdio.h!

(.include tasl- _ sg .h ϋ _ r..~_ 1 Li'- -. ιf.a>_ι J- c « h

pur.ip_ o.Ti_dis. ( f ) frame .* ;

1 -i SetPicHeader '• f— name, S-d ,- -th, wor. buf > ===• - J

bottom = th.YOffset; right -= th.XOffset t th.;: l; top = th.YOffset t th.y i;

for ( i - bottom: top; 3 tt .

blastro.-. < work_bu , left, right, i ) 5

/* display it */

f lose, df .

.-jrapl . •' p ir.iμ _ μ J .... c

ttinclude "vars.h" ttinclude stdio.h '

if ( ul 1_ w_ dth_ rame .f) ) b 3 as L _ f r arne < ) ; else show_f rame_by_rows <f);

blast frame l f rame -* r

unsigned ban. , targ_of f , bvteCount , rows._Jeft, row, .tun. chun. »-c;

for • row = T - b. bottom; row — r - b.tαα; row t*= 32 ) _ rows_left * = f — b.top — row + 1; bvteCount = rows_left = 32 " CHUIMI „3I2E _ rows_left * 512;

BetHddress <S*-tarq_off , .".bank, o, row, -1); t 0 * 5 f I a . 1. l! I

GetAddress ( S. j un k , * . aπ , O » row t 64,, — i) * -

SetSrcBank (bank) ; movedata (c ->segment, c — >offset, DESTBANK , targ_off, byteCount » 1)? c ■= c ->next chunk;

bhui. ft a.utr by fuWS (f ) tr __ιnt_ *t

:hunk K-c = f — > irst chunk; insigned row_length = (f — >b. right — f ->b.left) + 1 p Limp _ch unk () 5 y = f ->b_ bottom;

;.r . ; c I- MULL; c = c ->neκt_chι y = ** ρumρ_chunk (c, f ->b.left, y, row_leπgth)

ι_n ιι * s-'_ j unsi ned ; , y, row_length;

unsigned i , offset = c —>of set;

-f - lf b- r i movebytes (c -.'-segment, offset, my_ds ( ) , work_.buf , row_length) 5 blastrow <work_buf, .; , >ι + row_length - 1, y + i) ' .s offset t= row_length; J retLirn y + i ;

f Lil 1 _wi dth_f rame (f ) rame *f ;

return < <f ->b. right - f ->b.left> t 1) == M3_R0W_LE GTH:

- 52k -

graph/ utentry.c put mapClO, count, array) int io; /* array in IO space to Write to */ int count /♦Number of bytes to read */ char * rray; /♦pointer to byte array */

int i;

for (i=0; i(count; i++) io_out(io,*(arrayt ) );

graph/servi ce_dave. c

ttinclude "vars.h" ttinclude - stdio.h ' '

* "*t : ..] _ u __ _ i J nod n-' i>: •" _ r. * . '_ > ι " : 1 '> " . " .

__oρε-n_screen (dave) unsigned dave; ϊ. unsigned i ;

I 8_lnit .targa, S) ;

/if clear_genlocl'_trιgger ;

-■' SetGenLoc, < 1 ) ;

whil (GetLιne<RASTERREG ! = 100)

while .GetField O '= 0)

set _genl od _ tri gger .d ve αr.tp ...•_. __• .1 I" i

«

_open_screen_warm () C pumρ_colour_.τ.ap5 (red_map, green_map, b1ue_.τ.a )

_displ * _cash_i n (r) request *r ; r-

draw_cash_in (r->value2) ;

_di sρl ay * _pLiirιp_πuιTιber i ' . request *r;

draw_puιτιp_nu.ιτιber (r->value2) ;

d i sp 1 , μr 1 '-___-ϊ_- i"-- * e S i t_. s "c

draw_prices (r->valLie2 T r->value3, r->val ue4) ;

.displ ay_grade Cr) i-'squeiil ÷-i ,.

-5-2-1-

draw_selected_grade (r->value2, r->value3);

_display_preset (r) request *r;

_diεplay_credi t (r) reqLiest *r;

draw_credit (r->value2, r~>value3)

.displ£ιy_canc i <r. request * -

draw_cancel (r— >val ua . , r->value3)

_dι spl a _Ξys L ende r. c_--i (r •

draw_system_cancel (r->value2, r->value3 )

_displ ay_stri r.g tr) request *r ;

draw_recei t_string (r->string_data, r—>value2, r->value3) ;

_display_centred (r) request *r;

dra _receiρt_centred ■.r—>string__data, r—.-valL.e__.. vai ue-.

- value4)

_displ y_reset_arrow ()

draw reset arrow ()

_d i sp 1 ay * _neκ t _ar r ow . r ) request *r;

ira arrow (r— >value2, r— >value3)

_di spl ay_i ni t_arrDw ( )

draw init arrow () *■

_disρl y_ρreset_label (r )

-52.9-

draw_preset_l bel (r — " 5value2, r-/value3);

.display_tran_type <r) request *r;

dr " . .Sc.C LI OI " ι_ L v * pι - a i L. __•__; , r-

_d sρlay_card_type (r) request *r;

draw_card_type (r- alue2);

_d. spla\ ' _cash_ιn_low 'r) request *r;

draw cash in low (r- alueZ');

_ri3 ΞP I ?._C1FΛI _ prep v * ( )

draw_ciear_prepay ( > * j

. di spl v_load_bι ts ()

. r. J 1 a I i . t-_ _. i .-■ i <_. i _. - * -- i ,

- ≤-^ > '

graph/unpack_map.c

#include "vars.h"

unρack_map (packed, red, green, blue) unsigned char *pac ed, *red , *greeπ , *blue;

int

-for ( t = i = O * i < COLOUR_MAP_LENGTH * ι i++) C blue C i 3 = packed C t++ 3; green C i 3 — packed C t÷+ ; red C i 3 — packed L t++ 3?

>.-

graph/vars.h

#ιnclude "graph. h"

#ι ncl nde " /user .'steve/ t rga/ tεirdev. h "

-H-detir.e VARIABLE t l se

#de-fιne VARIABLE et.tern

#eπdι -f

frame *-fιrst_-frame () , ti-πe,, L...-f ame () , * t- nd_-frame ( ) Ϊ

#defme ROW_PIXEL_LENGTH 512

V R1ABLE -fra e *trame_top5

VARIABLE char wort bur C Z * COLOUR MAP LENGTH s

VARIABLE MSBtrue. *m8n A I BLE T RStruc t rq ,

VARIABLE char red_map L C0L0UR_MAP_LENG7H 3 VARIABLE char green_map C C0L0UR_MAP_LENGTH 3 VARIABLE char blue_map C COLOUR_MAP_LENGTH 3

graph/int/graph_iπt.

/* graphics task inter-face routines */

#inelude "" ' "graph.h"

static unsigned graρhιcs_tasks extern request dr;

1oad_frame (name) char *name;

*L

COPY_SAFELY(dr. string_data, name) ** return grequest (LO D_FRAME, 1>

load bit; O

return grequest (LDAD_BITS, 1>

qraphics_ram_usage . ()

return grequest (RAM JSAGE, 1)

Λ _~z - * X tf. V " r " dtlltsf rL. * 3*r.π , P. cU t^ ' t π ~ z- 1 pnod IS *Z * S S Π «

char *na e; r -_.

COPY_SAFELY(dr.string_data, name) ; grequest (DISPLAY_FRAME, screen);

unsigned screen

grequest (OPEM_SCREEN, screen)

Dpen_screen_warm (screen)

qreq e. . OPf SCREEN lttRII . _- _. r" f

graph i cs_sorver_ al 1 ve r

1 r I fc 1 Ll I . • _-,

dregιster_r.ame (0, ΘRAPHICS_MAME, f-jun! , ^-answer , _.jun. ) s return answer;

d"i -.i . I "i . pi"ι .- a- •<_- '>•>■" .- p "i.. i r eq111 t.' i... ι y ~ -< i•_-■.1 „ ••-11r■κ>r • .r, i-jr * ■- ■"< ~ zι ' ..-,, g.11 --.r , ui ■ 1 ι= adι=d , .- upf.'i

c dr. val ue2 = regul ar; dr.value3 = unleaded; dr.value4 = super; grequest (ALL_PRICE3, screen);

display_c1 ar_prepay (screen) unsigned sereeπ;

grequest (CLEAR_PREPAY, screen);

di5play_tr-aπsactiDn_type (screen, langLiage, type) unsigned screen, language, type;

dr.value2 = language? dr.valueS = type; greqLiest (TTYPE, screen) ;

displ y_cash_in (screen, csnts_in) unsigned screen, cents_in;

dr.value2 = cents_in; grequest (CASH_IT , screen);

i - P i-.m'j iuiB er . s ϋ...I..-, -?. "

unsigned screen, purnp_number ; C dr.value2 = pump_number ; grequest (DRAW_PUMP_NO, screen ) ;

di spl άy_ρreset_l abe l ι__,creer., l nguage, afiιθ-.ιr,L unsigned screen, language, amount; r

dr.value2 * = language; dr.value3 = amount; grequest (PRESET_L BEL, screen);

di p I av_grade .screen, grade, language ) Lir.s. qned screen, grade, 1 ar.quagei 1 ,

dr.γalue2 = grade; dr. val el- — language; grequest 'GRADE, screen);

dιsplay_ρreset (screen, preset, language) unsigned screen, preset, language;

dr. lued' = preset;

.Jl"- VriJ Lie - - J ..-M " . -ILU ' Ci'- i, ut w lifeSi" ' 1 !ΛEC.Γ ', , :-\~-i t.-.;-'. I '■ ,

- B>«=>-

display_card_type (screen, type) unsigned screen, type;

ύ ~ .value2 ~ typ ; grequest (CARD_TYPE, screen)

displ y_cash_iπ_lo (screen, amount) unsigned screen, amount; r dr. valLie2 = amount; grequest (CASH_IN_LOW , screen ) ;

disρlay_user_cancel_credit (screen, credit, language) unsigned screen, credit, language;

dr.value3 = language; grequest (CANCEL_CREBIT, screen) ;

display_system_cancel_credit (screen, credit, language) unsigned screen, credit, language;

d ..va1u &2 — eredi11

dr.valued = language; grequest (SYSTEM_CA.--.CEL, screen);

displav_credit (screen, credit, language) Linsigned screen, credit, language;

dr.value2 = credit; dr.value3 = 1anguage; grequest (CREDIT, screen);

dιsplay_string (screen, string, , y) unsigned screens char *strιng; Lins. gned -. , y;

dr, value2 = >', ; dr.value2. = y;

- " l - ' r ' ,7 _5AFLt Y ■■ dr , 1" r ι . ■■ _._ _!«•-_ n ,, = '■ . no • - grequest (DRAW_STRJMG, screen ) ;

display_stπng_centred (screen, string, ;t1 , \2, y) unsigned screen; char *strιng; un?] gned 1 2, v »

- r^-

dr.value2 = xi; dr.value3 = >.2; dr.value4 — y;

COPY_SAFELY(dr.string_data, string) ; grequest (DRAW_CE TRED, screen);

static greqLiest (opcode, screen) unsigned opcode, screen;

unsigned jun..;

i-f ( graphics_task **** = 0 ) dregister_πaιτιe (0, GRAPHICS_NAMΞ, fejunk,

_.graphics_task , S-jLink)

dr. opcode = opcode; dr. val ue 1 = screen; SEND (graphics_task , ..dr ) ; r e t u. r n d r _ v a.1 I el;

-53 -

graph/int/graph_int2. c

/* graphics task inter-face routines */

#ιncJ.Ltde " graph, h"

stat * unsigned yi * aph L CS__L =.i- _ extern request dr;

display_arroh (screen, arrow, color) unsigned screen, arrow, color; r τ. dr.valLie2 = arrow; dr. value " .. = color; return grequest (NEXT_ARR W , screen ) ~

i spl ay_resefc_arrow t screen ) unsigned screen;

eturn grequest" ARRLII»I , Ecreer.i

ispl ay_inιt_arrow .screen) unsiqned screen;

--■ l-i i r. i I - ..,i |H> ( T M ;.RI " U" h r-ζ.π

static grequest (opcode, screen) unsigned opcode, screen;

unsigned jLink;

i ( graρhics_task * == 0 ) dregister_πa!T.e ('•-', L.RAPHIL--;_> NR'rit, -...Link,

../.gr phics_task, _.junk)

dr. opcode = opcode; dr.valuel = screen; return SEND (grap ics_task, ..dr) ;

ar «uι - ι/ utils/ ' di :-pι av-f

"'-sin large, argv ) int argc; char -s-argvC3i

displ ay_ rame iwui Qv-r. ID) ar gv ' 1123 ) ;

>=-! se

-inff ( •• display fra. T .e _, Creen p .

- Ci - B t _.n_nun . ber ) .

-S4-I-

graph/uti1s/display-f .map

.Segment: 1 OOOO to 152a (5417 bytes) . Segment; 2 0000 to 02DS (729 bytes) .. jcαmeπt: 3 02D9 ho 0330 (lώft .1 oral si__e is- 1SAA 'P I4; bytes DOt ) 0021 <My_tty> DOO O ώB <l y_cd_nid.- CO1 0A04 <sprintf> COl ODFA ungetc> COl 03BB <strncmp> COl OEOO -.-f-flush.- COl OBBA dregister_rιaιτιe.:- CO L ODώO '• find_admin " COi 0E24 (rewind)- CO1 OOBD load_-frame.'- C 1 0FD3 '.unholdi * COJ 105E ' emset ' :■ DOO 002E •'•!End_o-f _tree COl 0E6E 1 epi l ogue DOO 001A <Error_status DOO 0061 <User_num'.- COl 10EF •" ' -f roun > D 'j '.' 1. E_ , _perιfti r COL υ 1L d l s J / .-" r c_..J ι r.

^ -~_-

COl 0241 <display_bonsoir>

COl 012A <open_screen>

COl 0E36 <st ca >

DOO 0012 <E; * c_pc

COl 03BE <printf >

COi v-i iS ^strn py.--

COl 1009 <εet_int_vec>

D00 002 <stderr>

DOO 0010 <Exc_fp>

COl OiFB <display_caπcel_credit:

DOO 0034 stk_limit

DOO 0022 stack_base

DOO 0067 <Dads_nid>

D03 02DB <dr>

COl 01B5 <display_grade>

C01 0E54 <abort>

C01 0E4S <strlen>

COl 0DE2 < open>

DOO 0078 <User_spare>

COl 0E3C < trcmp>

COl 0E30 <breakable>

DOO 0030 <File_list>

C01 016F <display_prices>

DOO 0070 <Fstack>

DOO 001E <Dads_ , tid>

DOO 00 __ --_. . Arqe>

DOO - 02C --.Free list. ; -

-sq^-

DOO 0018 <Exit_status>

DOO 0008 < EM c_al 1 o >

COl 0FA3 <vc_create2>

_ COl OFD? <time_slice>

COl FA9 vc_create3

DOO 0069 My_tty_nid>

DOO 0065 < My _π i d >

CO 1 005E ep i 1 ogue

COl 0102 < di pl ay _-f rame)

DOO OOOO <User_sp>

DOO 0026 <stdin

C l 1364 <-ftσstr>

COl 0DD6 < real loc >

COl ODDC <-free>

DOO 0028 < stdout >

COl OFAF <ker_vc_destroy>

COl ODEE <qetc>

DOO OOOC <Exc_ρ ndi ng >

DOO 0002 <User_ss> f COl 00E8 < graph ics_rarn_Lisage >

COl 0EC6 lmodr

- A COl 0084 <main>

COl 0E42 <strcpy>

COl 0FB5 <de-f_server

D 00 00 V " 2 < C a j.1 __ s t a c k _ p t r >

DOO 00 iC <Mv tid>

-^Mr-

COl 0E12 <fget>

DOO. 0025 <My_priority::

DOO 0060 Code_- l gs>

COl 0ED5 divr

COl OFCD <hold>

COl 01DS <d i sp 1 ay_pr eset > DOO 0076 < Check_ρoi πt_sp > Ol 100F <alloc_ em> COl 0198 <display_cash_in: COl 0E4E <send> COl OFF! <set_user> COl 0067 stk_over-f 1 ow

COi 14A0 <extract_digit> COl 0258 < d i sp 1 ay_st r i n g > COl 0F9D <vc_create> DOO 0020 < Br eak_count > COl 107F <atoi> COl 0E06 <t print > COl 0F97 COl OFEB <set_prior ty; COl 11EB <*fscale> COl ODCA < eal loc > DOO 0034 <_Argv> DOO 00/4 <Seqn.ent table pti

_- ' .>6u ■; e .1. e a s e ... . ■■

COl i-Licbeq

- ^o-

COl OFBB <set_acc_ lags.

COl 0352 <strncat>

COl 0E18 <*fput>

DOO 0024 <Cιτιd_*f1ags>

COl OE . fTlLll

C01 1 42 z ero

COl 0E60 puεhdαuble

CO1 1003 < et_iπt_mask>

COi 0FE5 <force_ready>

COl ODDC c ree>

graph /uti Is/displays. c

ttinclude .stdio.h

* ma n lartjc, argv) _ '. u g . char *argvC35

i-f ( argc '= 5 ) tfprintf (stderr, "displays screen string .. else dιsplay_5tπng (atoi (argvC 11 ) , argvC23, atoi .arg-i H " j) . atoi .ar .- L4 " l >

-ft-

graph/utiIs/displays, map

.Segment:! OOOO to 0771 (1906 bytes)

.Segment:2 OOOO to 00B3 (ISO bytes)

.Seqmeπt:2 00B4 to 00E3 (48 bytes)

_ r- i I-, -i - I) \ l_. -J z_ _. _=- 'O_-■__• . __. J. ■____• ) UΫ Kb

DO 0021 <My_tty>

DOO 006B <My_cd_nid>

CO1 05B4 <ungetc>

COl 0341 <strncmp>

COl 05B < -flush

CO1 0374 <dregister_name.

C01- 051 <find_admin>

C 1 05DE <rewiπd

CO1 00ED ' .. 1 oad _f r a.fiie >

COl 0656 <uπhol d >

CO1 0693 '.meiTicpy >

COl 06E1 '-.iTieinset

DOO 002E -En d _ o t _ f r e e >

DOO 001 < Er r or _st atLis >

DOO 0061 < User_num >

DOO 0014 ■: . EK C _p er i t >

CO1 022B <d i s 1 ay _cr edi t !

COl 015A <open_screen >

CO1 05F0 <strcat >

L> ; ._>0 0 12 •: -. fc..-. C p c >

- \-

COl 068C -.set_ιnt_vec.r

DOO 002A stderr s

DOO OOIO .E>:c_-fp '

DOO 0034 st._lιmιt

DOO 0022 stac. base

'). . ) Jl l, ι . displ y_gr d abort - str1en • fopen r User_spare strcmp - brea. aole Fιle_lιst di pl y_ρr ces Fstac. Dads_tιd Free_ l t

E..c_al 1ow - vc_create2 time slice

COl 062C -.vc create: m

!| ' .' ι_>' i 11 ri >i

CO 1 005E ep i 1 ogue

COl 0132 display_frame

DOO OOOO <User_sp

DOO 0026 <stdin>

CO1 0590 <rea11oc>

COl 0596 -(-Free)

DOO 002B <stdout>

COl 0632 <ker_vc_destroy>

C01 05A8 <getc>

DOO OOOC E;ic_pending>

C01 0113 <graphics_ram_usage.

COl 0084 <main>

COi 05FC <strcpy>

CO1 O. <def ser v.

DOO 0072 <Call_stack_ptr>

DOO 00 IC <My_tid>

C01 05CC < get>

DOO 0025 <Hy_ρriDH-ity>

DOO 0060 <Code_f l gs>

C01 0650 <hold>

DOO 006E <Ndp_save_area>

COl. 0208 <display_preset>

DOO 0076 <Check_point_sp>

CO 1 0692 < al 1 oc_mem >

Cϊ>i . OICB -αisρlay cash i..,- υ& '-.. St. o .

____.< < . —

COl 0674 <set_user>

COl 0067 stk_over*flow

COl 0248 <display__string>

COl 0620 <vc_create.=

DOυ 0020 'Brea.-_coLint '•

COl 05CO .tfprintf.-

COl 061A • * c_send_reply."-

COl 066E • , .set_prιority>

COl 0584 .ealloc

DOO 0034 -._Argv

DOO 0074 • ;Segment_table_ptr.r-

DOO OOάD ..F-.eiease_rιUιT.: :

COl 0083 -ruebeg

DOO 0004 . E..c_bιts

COl 064A * .escape_tty -

COl 0053 prologue

CO 0680 modify_f1ags.

COi 05E-! i orwar

DOO 0063 -.Team_num"

DOO 007E ::Qdb_tid

COl 0171 -.graphics_server_alive!

COl 05D8 . " fiseek.-

S ' ( " fc' . C fc'j ' I. I l I

-- -2--

C01 007D <e.-.i >

CO 1 05C6 < t sp r i n t -f >

COl 0698 <copy

COl 067A <set_slice? ; *

DOO 0038 TEMP

DOO 0062 <SraL.p__nu.!i

COl 05AE <putc>

COl 05A2 < close>

CO 1 0614 < unb eakab 1 e >

COl 0662 <task_in*fo>

COi 063E < set _acc_ lag.

COl 0303 <strnca >

COl 05D2 < put>

DOO 0024 <Cmd_ l gs>

COl 06C5 <zerα>

COl 0686 <set_int_.τιask:

COi 0668 <force_ready>

CO1 0596 <cfree>

graph /uti ls/load_bi ts.

♦.include -.stdiα_h>

main O

_ t-fpr .r.l-f s O ' ii ., "!'. ' . "I ' r. " , . o _b i I -- ' ■ > -

s <+

graph/utils/load_bits. map

.Segments 1 OOOO to 07D6 (2007 bytes) . Segment_ 2 0000 to 009F (160 bytes) « Seαmeπt.3 00A0 to 0147 (163 bytes )

:My_tty>

*iiy_cd_nid>

!ungetc>

[di spl ay_preset_l abel

.strncmp >

. -flush >

. d r eg i st er _π ame >

,-f i nd_adιϊti n >

'. rewind > load_f rame>

:.Ltnhold> -.τιeιτιcp

CO1 07B6 ::iT!e. * --;set>

DOO 002E nd_ot _t ree>

COl 01 3 :.di spl ay_cl ear_ρreρay

DOO 001A Error_status>

DOO 0061 .User_num>

DOO 0014 E.ϊc_per i t>

--' .i _£Q-_:> - " d i spl ay __c„ * rd _ typp '' --

02CO .disnlav -redi ■- :

COl 0135 <open_screen>

CO1 06C5 <strcat>

DOO 0012 <E>'c_pc>

CO1 03A3 <strncpy>

CO1 0761 <set_int_vec>

DOO 002A 'stderr"• bυ0 010 ■■.E:: _f-p:■

COl U29D (display_caπc5l_crec.it)

DOO 0034 st _limit

DOO 0022 stack_base

DOO 0067 <Dads_nid>

DOS 00A2 <dr

COl 021D <disp1ay_grade. :

COl 06E3 =-abort> *

C L 06D7 '.strlen.

COi 0671 open>

DOO 0073 :::User_spare

COl 06CB -■ strcmp ' .-

CO 1 06T3F : brea αb 1 e ' -

DOO 0030 -.:File_iιεt.

COi 0280 !.dis i_.ιy_ca_r ' h_in_iow-

C01 017A <display_ρrices.:-

DOO 0070 <Fstack>

DOO 00IE <Dads_tid

DOO 0032 ; : ' _Arqc>

L t ' I O 11,, i l . i ... __ ϊ I ' i i i -- -.I . - 1 i i . '• - |. _

(Jw ) ι i U'i'2' . ! i"ι '.-' _ ' . - '.

— -^ ■ 1 ^ —

DOO OO18 <E«it_st tus

DOO 0008 Exc_allow>

COl 06FB <vc_c ea e2>

COl 0731 <time_slice>

COi 0701 < -vc_ create3>

DOO 0065 <My_nid>

COl 005E epilogue

CO1 01OD <display_-fr e >

DOO 0000 User_sp>

DOO 0026 <stdin>

COl 0665 <realloc>

COi 0668 <tree>

DOO 0028 <stdout> .

COl 0707 <ker_vc_destroy>

COl 067D <getc>

DOO OOOC <Exc_pending>

DOO 0002 <User_ss>

COl 00F3 <graρhics_rarn_usag_

COi 0084 <main>

COi 06D1 <strcpy>

COl 070D de-f_server> •

DOO 0072 < 11_stack_ptr>

DOO 00IC <My_tid>

CO! 06A1 <fαet> θ ! θθi__5 "-' y_ι-

DOO 0060 .Code_-flags.

COl 0725 -.hold;

DOO 006E -.Ndp_save_area.--

COl 0240 display_preset

DOO 0076 Checl _poιnt_sp

C 1 I ~>7-a ll.:.._ me * it

C l ' i JL. iEμla._cδ5 _ιrι

COl 06DD send

COi 0749 set_uεer

COl 0067 st. _over-flow

COl 02E3 dιsplay_5tπng.

COl 06F5 -'vc_create

DOO 0020 B eaI- .count

COl 0695 t print-f

LO L o6EF 'C__se _r epls *

COJ 0743 set_pπoπty

COl 0659 ealloc

DOO 0034 _Argv

UO. j<J~ '< _3C-qιfiCι L ' ']j 1 ■ -*_p "!" ' t

DO' ") 006D Reiease_nu

COl 0317 displ y_str ιng_centred

DOO 0004 E * '.c_bιts-

C01 00D9 load_bιts

COL 07IF esc pe_ttv

C 1 ' I ''-.' i I -'-' I.IJ. 'L

L'_ ! : , , _..' Ml' i i c'f|_-

.S≤2-

DOO 0036 SAVE

COl 06B9 <-forwa d>

DOO 0063 <Team_num>

DOO 007E <Qdb_tid>

CO1 01 C <graphics_εerver_al ive ' .

COl OόPiD -'r i _=-•=-(--.:..--

CO1 065F < alloc>

CO1 0719 <εet_e>.ception>

COl 007D <exi

COl 069B <tsprintf>

CO1 076D <co y>

CO1 074F <set_slice>

DOO 0038 TEMP

DOO 0062 <Broup_nurn>

COi 06S3 <putc>

CO1 0677 <-fc1ose>

CO1 06E9 <unbreakable

COl 0737 <task_into>

COl 0713 <set_acc__ lags>

CO1 03DD <strneat>

COl 0 7 <fput>

DOO 0024 <Cmd_f1ags>

COl 079 <zero>

COl 075B <set_int_mask>

COi 073D <force_ ready

COl 066B .LTΓ (_ __'.

graph/utilε/load_-frame.c

main (argc, argv) int argc; char *argvC-l;

print- . "1 s "/.d\n" , 1oad_trame (arqv 13 ) > ;

*

iph tti: 1 uS ad t r cinie . m μ

.Segments 1 OOOO to 14A2 (5233 bytes) .Segment:2 OOOO to 02B8 (697 bytes) .Segment:3 02B9 to 0360 (163 bytes) .Total size is 1804 (6148) bytes

L'OO i__ J. "• :'---•- L

DOO 006B <My_cd_nid>

CO! 09EE <spriπt-f>

CO1 0DE4 <ungetc>

COl 0375 < strncm >

COi ODEA < -f -flush >

COl 0BA4 <dregister_name>

COi 0D4A <tiπd_adιτιin>

COl 0E0E <rev-4iπd>

CO 1 0FBD < un h o 1 d >

COi 1048 <meιτιset>

D00 002E <End_o-f_ ree>

CO1 0E58 1epi1ogue

DOO 001A <Error_status>

D00 0061 <User_num>

C01 1069 <-fround>

DOO 0014 <Eκc_per it>

COl 0203 <displav: credit --

Col ϋ22i-' displa _ . or.s ir

COl 0114 open_screen -

COl 0E20 st ca '

DOO 0012 -.Eϋc_pc-

COl 03AS -print-fir

COi 0302 strncpy

C . OFF3 set_ lnt _vec

DOO M sLderr

DOO 0010 E.tc_*fp

COl 01E5 dιsplay_car.cel_credι t

DOO 0022 stac. _base

DOO 0067 -,Dadε_nιd-

D03 02BB dr -

COi 019F display_grade

COi 0E3E abort

COi 0E32 .strlen

COi ODCC -fopen-

DOO 0'.)7S Uεer_sρare

COl 0E1A brea. able

DOO 0030 Fιle_lιst

COl 0159 dιsρlay_prιces

DOO 0070 Fstac.

DOO 00IE Dads_tιd

DOO 0032 _Argc

U l - . * ,. ,_, , f I". i j. . . '

< S ~ Wl-~

DOO 0 1S <E;.it_status>

DOO 0008 <E;tc_a11ow>

COi 0F8D <vc_create2>

COl 0FC3 ' <ti e_slice

COl 0F93 <vc_create3>

DOO 0069 <M _t y_πid>

CO1 005E epi1ogue

COl OOEC < isplay_frame>

DOO OOOO <User_sp>

DOO 0026 <stdin>

COl 12DE <-ftαstr>

CO1 ODCO <real1oc>

COl 0DC6 <-free>

DOO 002S <stdout>

CO1 0F99 <k r_vc_destroy>

COi ODDS <getc>

DOO 000C <Exc_peπding>

CO! 00D2 * .αraρhics_ra'n_u5age.

COi OEBO lfnodr

C01 0034 <.τιaiπ>

COl 0E2C <strcpy>

COl 0F9F <def_server>

DOO 0072 < Call _εt ac k _p tr >

DOO 00 IC -'.My tid>

COl ODFC < et>

DOO 0025 <l y_priority

DOO 0060 <Code_-f1ags>

COl OEBF ldivr

**

COl 0FB7 <hold>

DOO 006E <Ndp_save_area>

CO1 01 2 <displ ay_preεet>

DOO 0076 <Check_ρoint_sp>

CO1 0FF9 <a11oc_.τιem>

COl 0182 <display_cash_in

COl 0E38 <send>

COl OFDB <set_user>

COi 0067 stk_over-flow

COi 141 <e>'tract_digit>

COl 0242 <diεplay_string>

COl 0FS7 <vc_create>

DOO 0020 <Break_count>

COl ODFO <tfprint-f>

COl 0F81 <vc_send_reply>

COl 0FD5 <set_priαrity>

COl 1165 <-fsc le."

COl 0DB4 <ealloc>

DOO 0034 <_Argv>

DOO 0074 <Segment_tab1e_ptr>

DOO 006D <Release_num>

COl 0083 $ucbeg

COi 027ό <d:i.SDlay strinα centred

^ ^ —

DOO 0004 <Exc_bits>

COl 0FB1 <escape_tty>

COl 0EB9 l od

COl 0053 prologue

COl 0FE7 <modi-fy_flags

DOO 0036 SAVE

COi 0EC8 Idiv

CO! 0E14 <-forward>

DOO 0063 <Xeam_num>

DOO 007E <Qdb_tid>

COl 012B graphics_server_alive ' .

CO1 0E08 <-Fiseek>

CO1 ODBA <mal1oc>

CO1 03C6 <-fprint-f>

COl OFAB <set_eMceρtion>

COi 007D <eκit>

CO1 0DF6 <tsprint-f>

COi OFFF <copy>

COi 0FE1 <set slice)-

DOO 0062 <Group_nuιτj>

C01 ODDE <putc>

COi 0DD2 <-fclose>

COi 0E44 <unbreakable>-

COl 0FC9 <task in-fo>

COl 033C <strncat

COi 0E02 <- ut>

DOO 0024 <Cmd_*flags>

COi 0E61 I ul

-»*

COl 102C <zero>

COi 0E4A pushdouble

COl OFED <set_iπt ι __ιτ.ask>

C i OFCF <τorc _r"-e dy

COl 0DC6 <c*free>

graph / uti le/open_εcreen.

main (argc, argv) int argc; char *-argvl__!; r

open_screen ( atoi (argvCill) ) ;

-5(ob-

graph/uti1s/open_screen.map

•Segment: 1 OOOO to 07A1 (1954 bytes) .Segments2 OOOO to 0097 (152 bytes) ■SegmentΪ3 0098 to 013F (168 bytes)

DOO 0012 <E>ι c_pc >

CO 1 02FE < 51 r n cp y >

COl 06BC <set_int_vec

-»*

DOO 002A <stder >

COi 01E1 <displ ay_cancel_cred.it

D00 0034 stk_lin.it

DOO 0022 stac _base

DOO 0067 <Dads_nid>•

D03 009 <dr>

COl 019B <display_grade

COl 063E <abort>

COi 0632 <strlen>

COi 05CC <-fopen>

DOO 0078 <User_spare>

COl 0626 <strcrnp

COl 061A <breakable>

DOO 0030 <Fi1e_l ist>

CO1 0155 <disp1ay_prices>

DOO 0070 <Fstack>

DOO 001E <Dads_tid>

DOO 0032 <_Argc>

DOO 002C <Free_list>

DOO 0018 < Exit_status>

DOO 0008 <E;:c_allow>

C 1 0 56 <vc__create2

CO1 068C <ti * ιe lice

-S-< S-

COl 065C <yc_create3>

DOO 0069 <My_tty_nid>

DOO 0065 <My_πid>

COl 005E epilogue

CO1 00E8 <disp1ay_ rame>

DOO 0000 <User_sp>

D00 0026 <stdin>

COl 05C0 <realloc>

CO1 05C6 <- ree>

DOO 0028 <stdout>

COl 0662 ker_vc_destroy>

C01 05D8 <getc>

DOO OOOC <Eκc_pending>

DOO 0002 <User_ss>

Coi oouE <.graphics_raιτι_usage

CO! 0034 <main>

C01 062C <strepy>

COl 0668 <de*f_server

DOO 0072 <Call_stack_ptr>

DOO 001 <My_tid>

COl 05FC <*fget>

DOO 0025 <My_priority>

DOO 0060 < Code_-f 1 ag s>

C01 0680 hold>

DOO 006E <lMdρ__s3ve_area>

C01 01 BE -.di pl ay _p reset >

DOO 0076 'Chec. _poιnt_sp ' r-

COl 06C2 - alloc_mem..

COl 017E -:dis lay_cash_in>

COl 0638 -'.send

COl 06A4 set__user i

C-a l - " sci- _o> i. ~ fJ o

C i 021 dιsρl -/_sL. _r.n

COi 0650 v * c_create

DOO 0020 Brea. _count

COl 0732 atoi

COi 05F0 t- pπntf

COl 064A vc_send_reply

COi 069E ' set_pπσr_ ty-

COi 05B4 ealloc

DO 11 0034 _Argv

DOO 0074 Segmeπt_table_ptr

DOo 006D Release.,num -

COl 0OS3 -fucbeg

C'. ! 027 " . " d i _jf l - _ -.- " r . ■ ....ceri L . * ρd

COi 067'tt escaρe_tt -

COi 0053 prologue

COl 06B0 modi- y_- lags

DOO 0036 SAVE

COl 0614 forward

— - ^ -

COl 0127 <graphics_server_al i ve>

COl 0608 <fiseek>

COl 05BA <malloc>

COi 0674 <set_eκception

COl 007D <e * it>

_.--_' A -jr o * •-. _.__pt 1 n UT .--

COl 06CS <copy>

COi 06AA <set_slice>

DOO 0038 TEMP

DOO 0062 <Broup_num>

COl 05DE <putc>

COi 05D2 <-rclose>

COi 0644 <uπbreakable>

COl 066E < et_acc_ lags>

COl 0338 <strncat>

COl 0602 <*fput>

DOO 0024 <Cmd_-flags>

COi 06F5 <zero>

COi 06B6 <set_iπt_mask>

COl 0698 <-force_ready>

C01 05C6 <c*free>

logger /l ogger . c

** #include "logger, h"

* ttinclude : '.stdi o. hi'-

*

I .' I i _ ' _' " " '_' > i -'- _ j _.-! " .-• ! r " I c'.ϊ __" !-• ' ' a ■■ '_ . * system crashes do not corrupt the - ilesystem #/

ttde- ine BREAi- _EXCEPTIO 2 ttde-fine LOG_FILE_SIZE 2048

FILE *log_-file;

main (argc, argv) int argc; cnar *arρ-C_lϊ r _ request r;

β . fer . li >

_ *

task = RECEIVE_ANY<_.r> 3 REPLY (task, fer); process (task, ..r ) s

- 5 2--

initialize (argc) int argc;

char *ti .Tiestamp C ) ; i nt t e m i π a.t e ( ) s

i (arqc * == 0) usage () ;

i-f ( register_πame (O, LOGGER_NAME, O) i= 0 ) abort ("logger can't register");

chdir ' (LOG_DIRECTORY) ; ake_new_log_-fi1e (timestamp (1) ) **

exc handler (BREAK EXCEPTION, 0, terminate);

iT.t_.ke_πe_ , -_log_tile (name)

_r

char sbα- C 256 1; int i;

zero (abu-f , siseo-f (abu-f) ) ; i-f ( (log_ * file = ** open (name, "wv")) != NULL )

LOG FILE SIZE / si_.e__.jv iauut .' _ ι -I—!

•fput (abu-f , sizeof (abuf) , log_file ) ; fclose <log_-f i le) ; log_*file = -fopen (name, "rwv");

fprintf (stderr, "ioggf-r \π" ) s

terminate ()

close (log -file)

I- ( O )

process (task:, r>

11 ".- 3 p i - e d t a I request -t*-r ;

switch ( r- opcode .

case RELOG: oper._new_log_-f 11 e ( ) 5 break; a e STOP. terminate () ; brea.-;

., V I - ι* .

opeπ_new_log_-file () C char -*timestamp ();

fclose (log_fiie);

log_it (tasl:., r) unsigned - task; request *r; r

int len; thar *5θurce_narfls < ) , m ssa C 3uo 3;

len = tsprintf (message, "7.5 %04κ Xs-XsXn",

50urc5_nan * iE (r—>oρcode) , task, timestamp (0)

if (thi< Tile " J. i_.pt_n_r.t_'._l __«c

fput (message, len, log_ ile) ; iush (1og_file ;

char *source_nafiιes t 3 = -C

"2260 ", "POS", "DAVE ", "PUMP ",

"VIDEO", "TOUCH", "EVT Q" , "BULLO" , "POWER"

-*-_•

* char #sourc"__name (s) unsigned s; _ returr. source names H s 1;

c air tbuf C 40 3; char *mname C 3 = -C

"Jan", "Feb" , "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

char -rt-ti mestamp (f or _ i l unsigned f or_f i lena e;

unsigned date C 3 3„

«• mo I

* d i

m, s

_5~7<©~ qet date

d = (dateC03 > 1) _. 0 * - * 3f;ι mo = ((dateC03 » S) & Oxf) - 1; y = (date COD » 12) + 80;

h = date 13 / 3600; = (date l 3 7. 3600) 60s

S — dcitSL 1 J "_ c_ϋ X

i ( date C 0 3 S. OκOOOl ) h += 12;

if ( for_filename ) tsprintf (tbu , "7.d7_s7.d_7-02d7.02d\0" , d, mname o , , , ) ; " el e

L≥μi li. T i. ι_DUτ , _α. ■___-/«□ .-_'__: .!- __. _l.'__. \ , u - Hindi. it; LJ.IL-J y * , h, rn, s ) ;

return tbuf _

this_ iie_ ull (len) int len * !

lonq ftell ()

returr. (ftell (log_file) t len ) > L0G_FILE_SIZE;

logge /logger . h

ttinclude "/user/steve/dave/dave_request.h"

ttd t l e LOGGER I AS! . Ui og er

:u-_l i '

*f defi e LOG DIRE TOR loqs"

#d e ine T2260 /* message sources */ #d efine POS ttdefine DAVE ttdefir.e PUMP H-define VIDEO ttdefir.e I ' OUCH ttdefine EVENT_0 ttdefine BULLOCH ttde ir.e POWER

ttde ir.e ST OF' IS udO S_'Ur

.rii-Tinfi K'-ILOG ' « seu o o! tr c e

<-~ 2 -

1 og q er 1 og g er _ map

.Segment: 1 0000 to 150E (5391 bytes) .Segment:2 0000 to 036A (875 bytes) •Segment:3 036B to 03C0 (86 bytes)

.Total size is 13D0 (6352) bytes

COl 005E epilogue

CO! 0067 stk_overflow

CO1 007D <exit>

COl 0083 $ucbeg

CO1 0084 <main>

COl 00D2 <initialize>

COl 0133 <make_new_log_file!:

COi 01A7 <usag >

CO1 01C9 terminate

COl 01E7 <process>

CO1 0227 <open_new_loq_file"

CO! 024C <log_it>

COl 0235 sour ce_n arne _>

CO1 02CD -'. t i (nestaiiip

COi 03BC < th i s_f i 1 e_f ul 1 >

COl 03F9 < regi st er _n ame >

COl 04BF < tel l >

COl 0524 <f pri ntf >

Cυi 0B4C <. sp r J. r - f f ' -

_- * tt-

_ ^3θ -

CO1 0DF8 <unbreakab1e>

CO1 ODFE pushdoub1e

COl OEOC 1epilogue

COl 0E15 lmul

COl 0E64 lmod

CO1 0E6D 1mod

__-01 ϋt/3 1divr

COl 0E7C Idiv

COl 0F35 <vc_send_reply>

COl 0F3B <vc_create>

COi 0F41 < c_create2>

COl 0F47 <vc_create3>

COi 0F4D <ker_vc_destroy * :

COl 0F53 <def_server>

CO1 0F59 <set_acc_ lags>

COl 0F5F <set_e.:ceptiαn>

COl 0F65 <escape_tty>

COl 0F6B <hold>

COl 0F71 <unhold>

CO1 0F77 <ti.τ.e_≤1ice>

COl 0F7D <task_iπ o> O! 0FS3 <- or._:e_ready> Oi 0F89 <set_priority> O1 0F8F <set_user>

COi 0F95 <set slice)

COi : 1a

il. ιιιOf.ιC| '

, * ,-r.

- ^ '2 --

DOO OOOO <User_sp>

DOO 0002 <User_ss

DOO 0004 <Exc_bits>

DOO 0008 <Exc_al1ow>

DOO OOOC <Exc_peπding>

DOO 0010 <E.-.c_fp> '

DOO 0012 <Eκc_pc>

DOO 0014 <Exc_permit>

DOO 0018 <Exit.s atus>

DOO 001A <Error_status.

DOO 00IC <My_tid>

DOO 00IE <Dads_tid>

DOO 0020 <Break_count>

DOO 0021 . <My_tty>

DOO 0022 stack_base

DOO 0024 <Cmd_flags>

DOO 0025 <My_prio ity>

DOO 0026 <stdiπ>

DOO 0028 stdout>

DOO 002A <stderr>

DOO 002C <Free_list>

DOO 002E End_of_free>

DOO 0030 <Fi1e_list>

DOO 0032 <_Argc

DOO 0034 <_Argv>

DOO 0034 s Jini * !-

DOO 0036 SAVE

DOO 0038 TEMP

DOO 0060 <Code_ l gs>

DOO 0061 <User_nuπι>

DOO 0062 <Group_num>

DOO 0063 <Team_nuιτ.>

DOO 0065 < My__.n i d >

DOO 0067 <Dads_nid>

DOO 0069 <My_tty_nid>

DOO 006B <My_cd_nid>

DOO 006D <Release_num>

DOO 006E <Ndp_save_area>

DOO 0070 Fstack>

DOO 0072 <Cal 1_stack_ptr>

DOO 0074 <Segment_table_ptr:

DOO 0076 <Check_point_3p>

DOO 0078 <User_spare>

DOO 007E <Ddb_tid>

D03 036B <iog_.fi le>

B03 036D <source_na eE>

D03 0371- <tbuf>

D03 03A7 <.τ.name>

l ogger/makef i l e

CFLAGS = -S

logger: logger.o

1inkobj 1ogger . o c= * lagger ιτ-=ioqqer„ map 1 * =/user/steve/dav. ort l gger. ap f=l,2 1 copy >1ogger. map copy logger /dave/logger

1ogger. o_ logger.c

-s^ -" i t'Ciq r. . J es

•f* log_2260.c l g_bulloch. c 1o _da e. c α. l~' _ t_ j _ .

1 og_ρo . c lσg_pσwer . c log_pumρ. c 1 og_touch. c lαg_vιdeo. c 1 request . c re] oq. c s _ oρ_ i oq = ."_

1 oqqer /i nt / 1 og_2260. c

#include "'"logger. h"

log_2260 (m. char * -frfnj

1request (T226 , > j

1 o ger / i n / 1 og_ ul 1 och . c

ttinclude ""'"logger .h"

* " * log_bulloch ( )

11-equest (BULLOCH, ) ;

logqer/int/loq dave.c

#include "-""logger,h"

log_dave (m) char * ;

1request (DAVE, m>

1 o g Q e r / i n t / 1 o cj ... e q _ c

ttinclude "" ' "logger .h"

n*

log_eq <m) char -K-m;

1 r equest i EVEN " F_Q , m )

1 og g er / i π t / 1 og _ρ os . c

ttinclude " Λ l ogge .h"

log_pos (m> char -J÷m'i

1request (POS, m) ;

1 ogger / i n t / 1 og_ρower . c

ttinclude "-'"logger . h"

Log_power ( m ) ch r *.τ.ϋ

1request < PuWER, m ) 5

- t ^tf- —

1 og ger / i π t 1 og_p urnp- . <

ttinclude "-'"logger . h"

log_pump (m) char * 5

1 request (PUMP, m.

I ogqer / 1 nt / 1 c_g_ t ou . c

ttinclude """'logger . h"

log_touch (m> char *m;

Irequest (TOUCH, m. ;

1 ogger / 1 n L / J og _V3 dc

ttinclude " logger,, h"

l g_vιdeo ( ; ch r -t-.Tii,

-illl Ξ. 1DEU, in i

1oαoer/int/lrequest. c

ttinclude "- ' "1ogger.h"

static unsigned logger; extern request dr;

1request (s, message) unsigned s? r

i-f ( logger * == 0 )

' dregister_name (0, LDGGEF-._r.Al E, § ' unt-:, Stlogger, S.junk) si

CQPY_SAFELY (dr. string_dat , message) % dr.opcode * = Sji SEND(1ogger, §.dr) ;

1oqqar int/make- ile

CFLAGS = -S +Wc,+u „ SOURCES = ec- iles OBJECTS = ©objects

-"-" directory. *(OBJECTS)

1 oqqer /i nt ob jec ts

log_2260.o 1og_bul1oc .o log_dave.o 1og_eq.o log_ αs.o 1og_ρower.o log_pump.o log_touch.o log_video.o 1request.o relog.o

1 ogge / i nt r e 1 o . c

#include """logger.h"

relog O

1request (RELOG, "" ) 5

-s^rø-

1ogger/int/stoρ_log.c

#include ""-logger.h"

stop_logger ()

1request (STOP,

1 g g er i n t / n ew 1 o . c

main () i relog ( ) ;

— loOO-

1ogger/utils/newlog.map

.Segment: 1 0000 to 0542 (1347 bytes) .Segment:2 0000 to OOSF (144 bytes) .Segmen s3 0090 to 0137 (163 bytes) •Total size is 067B (1059) bytes OO 0021 <My_tty OO 006B <My_cd_nid> 1 03F5 <ungetc> Ol 0132 < str n crop > Oi 03FB -F -f lush >

COi 01B5 <dregi ster_name> Ol 03ΞB <*find_admin>

COi 041F <re ind>

COl 0497 <unhold>

COi 04D9 <memcpy>

COl 0522 <memset>

DOO 002E <End_of__ ree>

DOO 001A <Error_status>

D00 0061 <User_nuιTι>

D00 0014 <E5.c_permit>

COl 0431 <strcat>

DOO 0012 <Exc_pc>

COl 010F <strncpy>

COl 04CD <set_int_v * ec>

DOO 002A <stderr>

DOO 0010 <Exc_fp>

DOO 0034 st _1imit

DOO 0022 stac _base

DOO 0067 =.Dadε_nid>

D03 0092 '.dr:=

COi 0441 " ,-ιbc-rl.

CO1 0443 .str1en.'

COl 03DD ::fopen OO 007S =.User_spare O1 009F <re1og.s Ol 0437 =-.strcmp> Ol 042B <breakable> OO 0030 <Fi 1e_1ist> OO 0070 -.Fstac..> OO 0032 «'._Argc - OO 002C Free_1ist> OO 0018 :E:.it_status. OO O008 E;;c_aiJo - ol U ό/ '' __ rs te Oi 4 -..tin.e_slice.- Ol 046D -.vc_create3:- OO 0069 <My_tty_nid:= OO 0065 •::My_nιd." .i.i lJ--.-.

-. &θZ -

DOO 0026 <stdin

COl 03D1 <realloc>

COl 03D7 <+ree>

DOO 002B <stdout>

COl 0473 ker_vc_destroy>

COl 03E9 σetc

DOO OOOC <Eκc_pendiπg>

DOO 0002 <User_ss>

C01 0034 <main>

COl 043D <strcpy>

COl 0479 <de-f_server>

DOO 0072 <Call_stack_ptr>

DOO 00IC <My_tid>

COl 040D <-f et>

DOO 0025 <My_priority>

DOO 0060 <Code_*f1ags>

COl 0491 <hold

DOO 0O6E <Mdp_save_area>

DOO O . <U ' hecI ■:_ρoin

CO1 04D3 <al1oc_π * ιem>

COl 0449 <seπd>

COl 04B5 <set_user>

COl 0067 stk_ ver-flow

C01 0461 <vc_create

DOO 0020 Break_couπt>

CO1 04υi <tfprint >

COl 045B <vc_send_ reply.

COi 04AF <set_pri ori ty>

COl 03C5 < c 1 1 oc >

«

DOO 0034 <_Argv

DOO 0074 <Segment_table_ptr:

DOO 006D -. ' Release_πuπι>

COJ 00C__. rue beg

DOO 0O04 '.E;ιC_bits ' .-■

COl 04SB -=..escape_tty.-

COl 0053 prologue

COi 04C1 <modi* y_flags>

DOO 0036 SAVE

COl 00B7 -.1request>

CO1 0425 or ard

DOO 0063 :Team_num

DOO 007E .Qdb_tid.-

COi 0419 ' .-fiseek.

COl 03CB =.:malloc>

COl 0485 •.set_e.;ception>

CO I θ7 -. an11.

CO I 4 " tspr Lntf

COi 04D9 .copy.-

COl 04BB -.set_slice>

DOO 003B TEMP

DOO 0062 <Group_nurn

CO l iz z -flc-sij

. -£>** -

COl 0455 <unbreakable>

COi 04A3 <task_in* o>

COl 047F <set_acc_flags>

COl 0149 strncat

COl 0413 < ut

DOO 0024 <Cmd_ lags>

C01 0506 <zero>

COl 04C7- <set_int_mask>

COi 04A9 <f orce_ready>

COl 03D7 <c-free>

mi sc/address. c

#include dev.h>

Addresε_of ( device ) FILE *device;

:ruct dev_eπtrv den try:

get_attr ( device, 8.dentry ) j return dentry. tty_ioport ;

-. * « -

usc/blastro . c

/* ~~ * * PutRow: Load a pixel array into the specified x positions

* *• in the specified row.

*

*

* usage". T.-.-" ni ' ..nd MS_

•K- PutRow(color ,5.1 ,,.2,y,screen. ;

* char colorCD; Pointer to pixel array

* int xi, x2; Starting and ending columns

* int y; Row coordinates

* int screen? Active Screen (see note below)

*/

#ιnclad * .- "/user steve/1 rga/t rdev. h"

extern TARStruct *targa;

blastrow (color, .1, .t2, y ) char f-cαl r- ; unsi cjneri si , .2 , v r,

* r

* int bank, offset;

GetAddresε(S*oftse , 2-ban. , ;.1 , y, -1);

Sc * -..-Ωr3._:c-..cr.i . or,! ' ,

set_extra_segment (DESTBANK) ; movebytes (my_ds() , color, DESTBANK, offset, x2 - xl + 1);

-

nu sc /eal . c

/* (c) 19S5, Phoenix Computer Products Corp. and Novum Organum, * * Inc. */ * /*

A date/time stamp is the number of seconds before (if negative) cr after 'i .- DO= _ | -ιveJ .. nu-ϊ.1- v 1., i'l-fij at 1 _?:'. *" .' -> .rudr.. αht .

Midnight belongs to the new day.

ealerr () is set after a call to ealjoin (), It returns:

error code variable in error valid range

0 no error n.a.

1 error in year ss.r 100 or

_<?2 - == vear -- 2019

2 error in month 1 - month - 12

3 error in day 1 = day = # in o.

4 error in hour 0 = hour = 23

5 . error in minute 0 = minute **** 5*-?

P r In c_.Lsr.1.' t ' 3 ΪD thfr vE ' l' With BI.tUr - , Yr 1.. eal oin (J tales either the year with century (in which case ealerr () can indicate a year-type error) or ust the last two digits (in which' Ct.se the century is implied, and there can be no ye r-tvpe error).

cal mttxt () takes a type code for which set of names to replace:

type # of names what gets reset

0 n.a. reset all to original Building Blocks names

1 12 set month names

2 7 set day names

3 4 ' set day-part names

The original names are- months January, February, March, April, May, June, . . . days Sunday, Monday, Tuesday, Wednesday, Thursday, « . . day-part Midnight, AM, Noon, PM

cal mtO formats a string from a control string similarly to strfmt () . There 3.ra a special set of conversion speci ication-

numeric conversions:

%C century and year (4 digit year)

(2 digit year)

(24 hour clock) (12 hour clock)

s_t lug conversions:

— - -

7.M month name as text

7.W weekday as text

%P part of day (AM, PM, etc.) as text

The usual strfmt options for V.ύ and 7.s work here for numerics and strings, too. For example, "7.02D" will produce a two-digit zero filled number for the day, "7.-4.3W" will produce the first 3 characters of the we da*-/ le t—a usted i a 4 character field. Lower case conversion speci iers sira OK.

Some popular date formats:

02 Jun 1985 "7.02D 7..3M 7.C"

January 3, 1985 "7.M 7.D, 7.C"

Friday, January 5 "7.W, 7.M 7.D" . . 12 5/35 "7.020/7.02D/7.02Y"

Some popular ti e formats:

23: 12s02 "7.02T:7.021s7.02S"

9:46A "7.Hs 7.0217..1P"

02:42 PM "7.02H:7.021 7.P"

Related calls fetch and set a DOS file ' s date/time stamp: Flsetcal O and Flgetcal O , which see.

*/

#include "pdefs.h" /*

#include "psys.h"

- 6-4O-

ttdei ine DAY_SECS C24L*60L*60L)

#define FOURYRSECS ( (4L*365L + ID * DAY_SECS )

#de ine BASEYR 1970

/* ealnow() is O on 1/1/1970 at midnight */ ttdefine DBASEYR 4

/# day of week, Jan. 1., Bf-VoEYR #/

#de iπe MAXYRS 68

/* tt of whole years in 2**31 seconds */

-ttdefine NLEAPS(ryr)

( ( ( (ryr)tBASEYR-l) »2 ) - ( (BASEYR-1)»2 ) )

static int _calerr, _csecs; static int _tzoff = 5*60;

/* number of minutes behind Greenwich for EST */

int calerr ()

long eal join ( yr, mth , day, hr, mi, sc ) int yr, mth, day, hr, mi, sc; r

1onQ eal ;

m_ * <"^ "~

int ryr5 int _mth_tab () fi

/* ERROR CHECKING */ if ( yr >= (BASEYR-MAXYRS) ?.& yr (BASEYRtMAXYRS) ) ryr = yr - BASEYR; /* 1902 - 203S */ else if ( yr -- lanSEYR'/.lυυ-MAXYRE.) I' yr 'U SEYRV. _υO+h * 4XY.-.E.) ryr = yr - (BASEYR'/ilOO) ;

/* 02 - 13S is 1902 - 203S */ else if ( yr >= o 2.S. yr -. (BASEYR7.100-MAXYRS) ) ryr = yr t 100 - <BASEYR7.100> s

/* 00 - 01 is 2000 - 2001 */ else

_cai err = CE_YR; ryr = 0; v.- = BASEYR? qc o onclof errch.. ?,

. mth ' 1 11 mth ' .: 12 ) _calerr * = CE_MTH|i else if < day -. 1 1 ! day .-= calmthlen (mth ,yr) ) TiJ e f . L. i'H i l|

else if ( hr < 1 ! ! hr > 23 ) ealerr = CE HR; else

_calerr * = CE_MIN; el_=,__

( sc < 1 1 i sc > 59 ) _calerr = CE_3EC.; else ealerr = NOERR;

endofer ch :

/* CONVERSION */

/* from 1/1/BASEYR */ eal = 365L*(long)ryr + NLEAPS.ryr) /* days to 1/ 1/yr */ t (long)_mth_tab (mth,yr) /* days to mth/ 1/yr */ t (long)day - IL.; /* days to mth/day/yr */ eal = 24L*cal + (loπg)hr;

/* hours to mth/day/yr h :00s00 */ eal = ό0L*cal ÷ (long) i

/ £ iT.in's to mth/day/yr hrumiϊOO */ t (long)_tzof . ;

/* min's to mth/day/yr hrsmis00 GMT */ eal = 60L*cal + (long)sc **

/ *- see's to mth/day/yr hrsmissc GMT */

return ( eal > ;

eal th len (mth,yr) int mth,yr;

rotii 11 h---l ,«r ) mth

long eal now. )

unsigned dateC 2 3;

int yr , mth, day, hr , mi, sc:

dav = (dateCOl 1) _■ 0; * 3f; mth = ( (dateCOl 3) S- O.tf); r = (deteCOl 12 ) t 1980?

hi- = dated J . 3600; πij. - .uciUfc wi J Λ. sc * = dated! 7. 60s

i ( date C 0 .1 .- 0x0001 ) hr += 12; c _.. .∑» - ii '

B S TITUTE S HEET

return ( caljoin( yr, mth, day, hr mi sc ) )

calnwor ( beg_cal , end_cal ) long beg_cal , end_cal ; r~

int ndays, nweeks, wkdayi , inept;

πdays . = (int) ( (end_cal - beg_cal ) / DAY_SECS) ; nweeks = (ndays / 7) ; /* whole work weeks */

/* take care of scraps */ ndays %= 75 wkdayi = cal kday ( beg_cal ) 5 " if (.wkdayi) r _ if (ndays > O) ndays-—; else if (ndays < ) ndaystt;

inept = ndays t wkdayi; if (inept < 0) ndayst=2; else J t iiπcpt ~~

ndaystt; else if (inept —— 7) ndays—;

else if (inept > 7) ndayst=2;

return ( 5 * nweeks -ι- ndavs .

ealsplit < eal, pyr, pmth, pday, phr, p i , psc ) long eal; int *PV'r, *pmth, *pday, *phr, *pmi , *psc;

,c

L int _ mth_tab () int y" .j mth, d s

eal -= (1σπg)_t2off * 60L; / * fi;-; stamp to local time */

/# take care of 4 year periods and insure that eal is positive */

yr __.- BASEYF. t 4 * (eal /FQURYRSECS) ;

* eal 7.= FDURYRSECS; if ( eal < )

* r * - cal t= FOURYRSECS; vr ~= 4;

- . >-

/* take care of time part */

if ( psc )

*psc = eal "/. 6 L5 eal /= 60L;

if " ( pmi )

*p i = eal 7„ 60L; eal /= 60L;

if ( phr )

*phr = eal '. 24L; eal /= 24L?

/* take cars of date part—eal now has # days since 1/i/BASEYR */

day = (int) eal;

while ( day >= _mth_tab (13,yr) )

/* month 13 is Jan of next year */ day —= _mth_tab (13,yr++) ;

i ( pyr )

s-pyr = yr;

for ( mth = 1; day >= _mth_tab (mth-t-i ,yr) ; mthtt >

if ( pmth )

* th = .Tith;

day —— _mth_tab (mth,yr)

if ( pday )

*pday = (int) (day+1) ;

long eal ;

int wkday; wkday = (int) ( cal/DAY_SECS WDBASEYR ) "/. 7; if (wkday < 0) wkday t= 7; return ( wkday ) ;

ealtimezone( zone ) int ** _on ;

int oldtz;

oldtz - _tzoff; _tzoff = zone; return ( oldtz ) ;

eal csecs ( )

return ( csecs) s

s atic _mth_tab ( mth, yr ) int mth, yr; r

static int _n.lE._I =

CO,31,59,90, 120, 151, 181,212,243,273,304,334,3653-; int ml; ml = _ml Cmth—11; i ( (mth > 3) && ! (yr & 3) ) ml+t; return ( ml ) ;

misc/cf iles

address. c blastrow. c eal . e dειves_rιa.τ.e. c

dr. c fatou.c movebytes. c movedata. c my_ds. c my_open. c print_ctrl . c

mi sc /daves names. c

la.r.e = α vSe- t,

ch r -ϊda '.s na e v n >

name C 7 _1 = n ι- '0 ' ; re urr. n me's

—wo- mi c/disal low.c

#include <magic»h>

#define COM OκOOiO

Φ.define MODEM_HANGUP 0x0001 #.de.- irre BF.fc.f-.K_ UKUUU..

disallow () r

unsigned bit_mas ;

bit_mask = COM ! BREAK ! MODEM_HANGUP;

Exc_permit C 0 1 = bit_mask; /* permit these */

E;- * c_allow C 0 1 = 0; /* but don't allow them *•/ unbreakable ();

πclu ". "/user/steve/ ave/dave_request.h'

request dr;

_ _

misc/f atou. c

fatou (b, 1) char *b; int 1 ;

i ong ()

returr. (int) f atol (b, 1)

long atol (b , 1 ) char *b; int 1;

1 ong atol ( ) ; char bb C 15 3;

memcpy (bb, b, 1); bb [ 1 1 = ' \ ' ; r eturn atol (bb) ;

fff -

mi sc /makef i le

CF AGS = -S +Wc,+u SOURCES - Scfiles OBJECTS * = ©objects

-directorys $(OBJECTS) Vμt! di i U'_.n>__

- Z1>-

misc/ ovebytβ-c

movebytes (sseg, soff, dseg, doff, bytecount) unsigned sseg, so f, dseg, do f, bytecount;

asm ( "pushf " ) ; /# save the flags #/ asm . "eld" ); >' * set the increment fl g */ asm ( "mov bϊ-; , s" ); /* save DS */ asm ( "push bK " ) ; /# save DS */ asm ( "push es" ) ; /* save ES */ asm ( "mov ds,141_bp_!" ); /* make DS the source segment */ asm ( "mov si , iώl_bp3" ) ; / * make SI the source offset */ asm ( "mov es,13I_b " ); /* make ES the destination segment asm ( "mov di ,20ilbpI! " ) ; /# destination offset */ asm ( "mov CH ,22Cb 1 " ); /# word count #/ asm ( "rep ovsb" ); asm ( "pop es" ) ; /* restore my ES */ asm ( "pop ds" ) ; /* restore my DS */ asm ( " op " ) ; /-"• restore the flags */

- 21+ -

mi sc / moved a t a . c

movedata (sseg, sof , dseg, do f, count) unsigned sseg, soff, dseg, dof-f, count;

/* save the flags •" ** •/ asm ( "eld" ); /* set the i crement flag */ asm ( "mov b.;,ds" ); /* save DS */ asm ( "push bκ" ) ; / * save DS */ asm ( "push es" ) ; /* save ES */ asm ( "mov ds, 14Cbp3") ; /* make DS the source segment */ asm ( "mov si , 16__bp3") ; /* make SI the source offset */ asm ( "mov es,lS bp3" ); /* make ES the destination segment* asm ( "mov di,20Ebp3" ); /* destination offset */

asm ( "mov cx,22Cbp3" ); /* word count */ asm ( "rep movsw" ) ; asm ( "pop es" ) ; /* restore my ES #/ asm ( "pop ds" ) ** / ■*•* - restore my DS -x-/ asm ( " op " ) ; /* restore the flaps «■/

i sc/my_ds. c

my_ds ()

asm ( "mov a.-; , ds" ) ;

miεc/my_open.c

#iπclude stdio.h> #include <setjmp.h

FILE *my_open (name, mode, jb, " c) char *πaπ)B, *.τιode; jmp_buf jb;

_r

FILE *f;

if ( (f = fopen (name, mode)) == NULL ) longjmp (jb, jc) ;

jc t= i!* return ;

- ^ ■■ -f-.

misc/ob jects

address. α blastrow. o eal . o daves_name. o di sal low. α d . o f atou. o movebytes. o movedata. o my_ds.o my_o eπ.o ρrint_ctrl . o

- - misc/Ddef s. h

/* p-fdef s. h */

typedef unsigned ushort; typedef unsigned uint; typedef int (*PFI ) ();/* pointer to function returning int */ y-pjed -f char #HDL; / » abstract data type handle */ ty edef long RHDL; / £ database record handle */

/* Some useful macros * /

/** General defines used almost everywhere **/

#defiπe AB3(x) ( (x) 0?-(x) : (x) ) #define BELL ttdefine BKSP ttdefine BLN ttdefine CPMEQF Ox1 /* <ctl-z> byte for eo in text files*/ ttdefine CRET ' \ι- ' ttdefine DELCH OKff iτ'-_ trine _J x __ ..-; .' ttdefine EDS

ttde ine ESC ttde ine FAST register- ttdefine FNAMSIZ Si ttdefir.e FOREVER for ( ** :>

_

ttdef i ne FULLBYTE ~0 ttdef i ne GT 1 ttdefine HIBYTE(a) (( (unsigned) (a) ) » 8) ttde ine INRANGE(a,b,c) : ( ( (b) (a) )?(a) s ( ( (b) (c) )?(b) : (c) ) ) ttdefine ISALPHA(c)

( ( ( 'a '<= (c) ) S... ( (c)<= 'z ' ) ) 1 ! ( ( 'A '<= ( c ) ) ..i?. ( ( c ) <= ' Z ' ) 5 ) ttdefine ISDIGIT(d) ( ( '0 '< <d) ) „...( (d><=' 9 ' ) > ttdefine 13DDD(a) ( (a) ..Ox01 ) ttdefine LNFEED '\n * ttdefine LDBYTE(a) ( (a) k ff) ttdefine LT (-1) ttdefine MAKEWORD(hi ,lo) (TDHIBYTE(hi ) ! LDBYTE(lo)) ttdefine MAX(a,b) ( ( (a) >(b) )?(a) s (b) ) ttdefine MIN(a,b) ( ( (a)<=(b) ) ?(a) s (b) ) ttdefine NO 0 ttdefine MOERR 0 ttdefine NOTFND (-1 )

/* NULL'S for various types of objects */ ttdefir.e NULLPTR ((char *)0)

/* use to ass null point r o f ncs*/ ttdefine MULLHDL ( (HDL)0) ttde ine NULL AL ( (short) 0) ttdefine NULLPFI ((PFI)O) ttdefine NULLLONG (dong)O) ttdefine NULLRHDL ((RHDL) ) ttdefir.e TAB ' \t '

__

ttd ef i n e T I MES2 ( ) ( ( ) < < 1 ) ttctef ine TDHIBYTE (a) ( (a)<<8) ttdefine TOLOBYTE(a) ( ( (a) »8) S-ϋxf f ) ttdefine TOLOWER(c)

((('A' <= c) ?-.. (c <= Z')) ? ((c) + ( 'a'-'A')) ; (c) ) ttdefine TOUPPER(c)

((('a' < = c) ..- (c < = 'Ξ ') ) ? ( (c)-( 'a'-'A') ): (c) )

char *syρushjmp () ;

ttdefine SYSETJMP if (setjmp (sypush mp ())==0) C ttdefine EXCEPTIONS sy opjmp () ; 3* ttdefine WHEN (errπum) else if (syerr ()= * =(errnum) ) ttdefine SYENDJMP else sylongjmp (syerr ()) ; ttdefine ALLOTHERS syerr ( )

typedef struct

ushort attr;

/* attributes of file _ system, hidden, directory etc.*/ x nq dtt.T. j /* creation date nd ti e of -Fil * i no sisε;/* size of file in bytes */ char πaιτ.eC14_l; /« name of file (or directory) */

FILEINFO;

/* reqister values to use with various calls */

ttde ine REGI3 struct REGIS

REGIS uint x ,bx ,cj-t ,dx ,di ,si ,es,ds,bp;

/* Seek mode parameters for B-tree r-eyε */

•K b. ypos ( ; — position to π.i- c rrenr .

ttdefine BK_FSTDUP —2 /* See. first duplicate KEY value */ ttdefine Bl- _FST -1 / * Seel first lev in tree. « / ttdefine B. _LST 1 /*- See. last key in tree. */ ttdefine Bl . LSTDUP 2 /* Seek last duplicate KEY value. */

/* b yscanO - get current, ne.it or previous . ey. */

ttdefine B! _PRV /# Retrieve previous ley. ** -/ ttdefine B. _CUR u '* Retrie e current I t- * v. *• .-.define B. NX7 / - Retrieve ne-ct key *'

/ * b. ysrchO - search for key. */

ttdef me B. _LT '*- Seel 1 .¥ 1 E «,' ttdefi e l.' _LE -1 -'* Seel- 1 £-• •• ttdef me _->. _E0 o ' 5 - θSt( 1 e- ttdefine B. _GE / 5* Seel- . ey *-, ttdefine Bl GT /# See. . ev */

/* Calendar Period types. */

ttd-f e iL i ) h i i

- - - -

ttdef i ne CAL_WKDAYS ttdefine CAL_ S ttde ine CAL_MTHS ttdefine CAL_QTRS ttdefine CAL YRS

/• * -"- Calendar error indicators. */

ttdefine CE_YR ttdefine CE_MTH ttdefine CE_DAY ttdefine CE_HR ttde-fine CE_MIN ttdefine CE SEC

/* CM — communications values */

_- >-

/* types for shape of cursor */

ttde ine CSR_HIDDEN 0 /* no cursor,. * ttdefine CSR_THΪM 1 /* one scan line cursor. */ ttdefine CSR_NORMAL 2 /* two scan line cursor (standard) ttdefine CSR_FAT 3 /* four lines. */ ttdefine CSR_BLOCK 4 /* Block cursor. */ ttdefine CSR DASH 5 /* Dash in middle of character.*/

V* Use the current (lαgged-in) drive */

ttdefine DR CUR DRV t)

/* Data type codes for search functions and B-trees. */

ttdefine DT_STR ttdefine DT_USH0RT ttdefine DT..LDNG ttde l ne DT_BY ' ιΕb

..define DT_SHQRT ttdefine DT UL0NG

/* DOS file attributes. */

T CRDIMnF' I ) ;. U reπu 1 r f i I

- € ϊ-- ttdefine FA_RDONLY Ox 01 /* Read only attribute #/ ttdefine FA_HIDDEN 0x02 /* Hidden file */ ttdefine FA_SYS 0x04 /* System file */ ttdefine FA_LABEL 0x08 /* Volume label */ ttdefine FA_DIR 0x 10 /* Directory */ ttdefine FA ARCH 0x20 /* Archive */

*- Field 11ributes„ ttdefine FLD NORMAL ttdefine FLD_AUTORET 0x0001 ttdef*ine FLD_NOREDSP 0x0002 ttdefine FLD_HIDE 0x0004 ttdefine FLD_LFRET 0x0008 ttdefine FLD_CLR_ON_FST 0x0010 ttdefine FLD_RTRET O 0 10 ttdefine FLD_ALTERD Ox0100 ttdefine FLD VARYING 0x0200

/* Field return codes for 'Special_key() ' function. */

ttde ine FLD C_IGNORE 0 ttdefine FLDRCJDONE -1 ttdefi e FLDRC_FBT -2 ttdefine FLDRC_N T -3 ttdefine FLDRC_PRV -4 ttdefine FLDRC_LST -5 ttdefine FLDRC_ERASE -6 ttde ine HL.i'K'L. n . 1 ~ι •:_-• = I- -

- 63 -

/* Here are the MSDOS bits for the MSDOS mode portion. */

ttdefine F0_RD0NLY 0x01

/* cursor key codes */

/* edit key codes */

ttdefine _INSERT 1 ttdefine K_DEL 2 ttdefine _CTLPRTSC 3 ttdefine K STAR MUMPAD 4

ttdefine !<_MI US_NUMPAD 5 ttdefine _PLUS_NUMPAD 6 ttdef i ne K_CTL_BRK 7 /* <cntl Xbrea > = <edi t-key , 7> */

/* Key types */

ttdefine KB_ SCII 0 ttdefine KB_CSR 1 ttdiefine KB_ FU ' C 2 ttde ine KB_EDIT 3 ttdefine KB_ALT 4

/* for building constants for comparisons */

ttdefine FNC_KEY(code) (MAKEWORD(KB_FNC, (code) ) ) ttdefine EDIT_KEY(code) (MAKEWORD (KB_EDIT, (code) ) ) ttdefine ASCII_KEY (code) (MAKEWORD(KB_ASCII , (code) ) )

/•s-ϋse only with capital alpha's, e.g. CTL_KEY('L') */ ttdefine CTL_KEY (code) (ASCIΪ_KEY( (code)-'A'+l) ) ttdefine CSR_KEY(code) (MAKEWORD(KB_CSR, (code) ) ) ttdefine ALT_KEY (code (MAKEWORD(KB_ALT,code) )

ttdefine KEY_TYPE( ey) TOLOBYTE(key)

H- t;τ 1 i it; .-..π. ? _ -,-—'iJiZ. . ey ; ._>_.__ • T I C. '. Ht_y /

/* *

* These definitions describe the bits in the keyboard flag.

_ —

•Jr Bit Subject matter Moaning, when bit is _

* 7 Insert state active

* 6 Caps-lock state active

* 5 Num-lock state active

* 4 Scroll-lock state active

* 3 Alt shift ke/ depressed #■ 2 Ctl shift ley depressed » J left-hand shift t _. •' de-prt_.si_.ed

* o rt-hand shift ey depressed *

**/

/* KBD -> key depressed */

/* KBS -> key state. */

ttdefine BD_ALTSHIFT OHOS

-..define BD_CTL3HIFT 0;;04 ttdefine KBD_LFSHIFT 0..02 ttdefine KBD_RTSHIFT OxOl

ttdefine BS_INSERT 0..80

Hαfefj.ne 1 S_CAP ■'.,,-■ ' t

Hdefine . BSJ UMLGC. 0-.20 ttdefine 1 B5_SCR0LLL0CI O,.lu

** Function Return Codes ** /

ttdefine RC_SUCCESS (0) /* Called function succeeded */ ttdefine RC . FAIL (-1) • * Called .function failed / -

ttdefine RC_EOF (-1) /* Signale END-DF-FILE EOF */

ttdefine RC_ESC 1 /* user ended input with <Esc> key.*/ ttdefine RC_ENTER 2

/* user ended by pressing <enter key.*/ ttdefine RC_SPECΣAL 3

/* user terminated input by pressing special */ ttdefine RC__G"v-ERFLW 4

/* fi ld full; insert inode, autoreturn; */

/* cursor in middle of field; user typed ascii*/ ttdefine RC_LO0P 9999

/* RC_LOOP is a special return code */

/* to signal that a processing loop should*/ /* continue as nor al. It is used in key input processing */

/* for field editing*/ /* and selection—by—cursor!ng input functions. */

ttdefine DB_F IL RC_FAIL ttdefir.e DB_SUCCESS RC_SUCCESS

/* Reserved Error Codes */

/* —257 to —320 Miscellaneous */

ttdefine SE_BAD_0BJ (—257)

/* Handle was not to proper type of object */ ttdefine SE_0UT0FHEAP (-258)

/* out of heap space during givemeO */ ttdefine SE SIVEFAR (-259) -

ttdef i ne SE_BADPORT (-260)

/* -321 to -384 10 system */

ttdefine SE_BADWRITE (-321)/* write error */ ttdefine SE_BADREAD (-322)/* read error */ ttdefine SE_BADSEEK (-323) ttdefine SE_REOPEMERR (-324)/* could not reopen ile */

/* -385 to -448 Database system */

ttdefine SE_BADPGID (-385)/* bad page id in record handle */ ttdefine SE_BADCELLID (-386)/* bad cell id in record handle */ ttdefine SE_NOFREEBUFS (-337)/* no free buffers in buffer pool */ ttdefine SE_DBPGBAD (-3S8)/* smashed database page */ ttdefine SE_DB0VRFL0W (-339)

/* database file too big (>30 megabytes) */ ttdefir.e SE -.ECT00BIG ' (-390)

/* Size of stored record bigger than page*/ ttdefine SE_BUFI CMP T (-391)

/* Buffer system already exists and is incompatibl */

/* with needs of database system,.*/ /* -449 to -512 B-tree Indexes */ '

ttdefine SE_BADKEYTYP (-449)/* bad key type in compare * ttdefine ΞE_BADDELKEY (-450)/* error during key deletion */ ttdefine 3E_BADBR00T (-451)/* Root of tree appears bad. */

/* Justification types for strjustO */

ttde ine STR_LJUST ttdefine STR_RJUST ttdefine STR CENTER

/* Symbol table wild card - ANY or IGNORE symbol class */ ttdefine SYT_ANY 0 /* when looking for a symbol of any type */ /**

* so-een attributes s

* bit number ON OFF MASK CONSTANT

0 reverse video normal video 0X01 VA_N0RMAL

1 high intensity low intensity 0X02 VAJ-JIINTY

2 blinking no blinking 0x04 VA_BLINK

3 underline normal fgd 0x08 VA__ULN

8 graphics chars TTY mode 0x0100 VA_GRAFΗIC3

9 '-'"'-normal '" " "'-special 0κ0200 VA CARET 10 '7.'-normal '%'-special 0x0400

*

**

ttdefir.e VA_N0RMAL ■J.iW ttdefine VA__REV ID 0x01 ttdefine VA_BLINK 0X04 ttdefine VA_ULN 0x08 ttdefine VA_GRAPHICS 0x0100 ttdefine V CARET

^ -G-i-M- ttdef ine VA PCT Ox 0400

/* colors for color text modes */

ttdefine VC_BLACK 0 ttdefine VC_BLUE ttdef me VC_GREEN

' -'C. CYAN VC..RED VC_MAGEN7A VC_YELL0W ά VC WHITE 7

/* .'ideo drawing constants */

ttdefine VD_N0ATTR -1

/* Don't use an- attributes wnen displa y ing ch s*. ttdef3 r.e VD__CURP0S -1

/*Leave this cursor coord at its current value*/ ttdefine VD_CURSTAT -2 ttdefine VD ALLOFΪT 0;.7FFF

/* v i eo modes */

ttdefine Vn_C0LR4O ttdefine VM_BWS0 ttdefine VM_C0LRSO " ..clef * _ no VM CDLRT.20

ttdefine VM_BW320 5 ttdefine VM_C0LR640 6 ttdefine VM_MONOCHROME 7

/* Window Movement return code bit masks */ ttdefine W_UNCHANGED 0 ttdefine W_ALTERED 1 ttijar-J iie v.__l_ι-iι~iPl_-__.l-' _-_.

/* Window Movement type- codes. */

ttdefine W_POSABS O ttdefine W_POSREL 1 ttdefine W_BUFAB3 2 ttdefine W_BUFREL 3 ttdefine W_SIZABS ~* 4 ttdefir.e _SIZREL 5

/* rsc Open modes. */

m isc/print_ctrl

ttinclude ,stdio.h>

ttdefine DEL 127 ttdefine END 5

Sf t?ι i e wLr , ttdefine NA1 -

prιnt_ctrl (s ) char *55

while (*5>

switch (* = )

1 ENu . " ) ; brea. .

ENQ: tfprintf (stderr, s brea. ; ACK: tfprintf (stderr, '- AC. ")

DEL: tfprintf (stderr, ' DEL " ) . breal ;

trμr-i-itf (=.tderr , ' NA. r " i ; brea!

if ( *-s OH 20 ) t f printf .std*rr " CTRL " > ?

else tfprintf ( stderr, ""/-c" , *s> *

5++"

:-ι prl n 1

ne pos/ ccept.c

ttinclude "const. "

static char _bu er C 300 D ,

_calculated_bcc,

_received_bcc,

*ρs.

*ρi ; static unsigned _message_recei ved;

Accept_message_ rom_remote ( >

/* until timeout or message complete */ r - uπsigned c;

while ( ( c = Neκtchar < ) ) != LINE_TIMED_DUT > r V

Store_received_character( c ); if ( Message_received ( ) . return 1; _ returr. 0.

Reset_messaqe buffer ( )

messaqe received

_recei ed_bcc = 0; zerα( _buf er, siseof( _bu er ) ) ; pi = _bu er; pe = _buffer + sizeof ( ..buffer ) - IO5 * marl safe end of buffer

Store_received_character ( c ) char cj u switch ( c )

case ACK: case NAK: case SDH:

Reset __ii.es sag e_b Lif fer ( > _calculated bcc = c? *p 1 t-ι = c a return; breal ;

if ( pi < pe ) /* there's room to store it */ C

*pi = c ; -' }; -_ r 'torc 3 tr '*- i f ' K- 1, j - J "' — --- [:'• " ) ! ' -' -Λ- ifiri-iiF. _ i; -. . I. ".

_message_recei ed = 1; /* so end of message */ _recei ved_bcc = 05

else /* otherwise keep going */

•C /* with the current message */ calculated bcc "' ■= c;

else

Reset _message_buf er ( ) ; /* must be full of junk */

C_ Lll 1 3d bi

return calculated bcc?

r.ι__ ._ •_.1. V BO

r c- L-Llf i i r fc. l_ fc.' x v t_ d b ι_ ■_ ϋ

char *The messaqe ( )

ur b er

Message_receive < ) return _message_received;

Is_εtart_of_ essage( c

return c == SOH c == STX c == ACK c = = NAK;

newpos/a i .c

ttinclude " Λ dave_reques .h" ttinclude "const.h" ttinclude "types.h"

__.>_et _.1 C ϋu <r»n>_.'; static request *r;

Service_client ( _who. _r > request *_r;

who = who;

it - V___.!_- ilBIIL

r—>valuel — O;

REPLY( who. r

swit>: ->oρcode >

case AUTHORIZE_CARD: authori e_card ( ) ; break; case CAPTURE_SALE: _capture_sale ( ); break; case PRuBEϊ probe ( ) ; break; break5

case DIE: _die( ); break case STATUS_OF_POS: - _pos_status( ); break; case GI E_l E_HEADER_l: _give_me_header_l ( ); break; case WHAT_IS_THIS_CARD: _decode_card ( ); break; case YOUR_INFO: __give._info( ); brea ;

CΆS-≡ YOUR_Fir_RECORD: . qivc. f_ t_record . . ; break; case RESET_STATS: _reεet__stats( ); break; case LOAD_FIT: _load_fit_record ( ); break; case LOAD_INFO: _load_info( ); break; case SET_LIN _TIMEOUT: _set_link_timeout ( ); break; case CARDS_EXPIRY_DATE: _cards_date( ); break; case GIVE_QUEUE_ENTRY: _give_entry( ); break; case ENABLE_TRANSMIS3I0N. _set_power ( 1 ); break; case DI5ABLE_TRANSMI3SION_ _set__pαwer ( 0 ); break; case SAVE_DATA: _sa/B_dataι ) ; break; case REGISTERED_HYDRO_USER: _register_hydro_user ( ) ; break; default: REPL ( who, r ); break;

unsi ned num;

return 1 <= num 8.?.. num <= 2;

r.r..ι_ <-_-_. ι i ι"|ι 'ft-

Register_hydro_user< r->value6, —>client > REPLY( who, r );

_set_power ( up )

Ξet_ρσwer_statu ( up ); Tel1_hydro_uεers( ) ; REPLY( who, r >

save data( )

Save al1 ( ) ;

REPL C who, r

_set_link_tirπeout ( )

Set_re ote_timeout ( r—>valuel .> 5 REPLY( who_ r ) ;

,give_entry( )

Pos_request *p , q»

n = r->valuelj zero< 8<q , sizeof ( q > ) ; for < p = First_request ( ) , i 0 ; p S. S. i < n ; i++, p = Me-i t_ requests p ) )

i ( p ) q = *p;

REPLY ( who, S.q )

cards date ( )

Transaction *t;

t **** Decode_transaction ( r ); r - ., v'a 1 ue 1 = Car d s __e.' p i r y _ yy mm ( t - ; -TR AC," ' 2 '

REPLY' who, r ) .

load infα(

Set_outlet_inf o ( r->string_data ); REPLY ( who, r ) ;

Set_ it_record ( r— > value 1 , r— >string_data > REPLY ( who, r );

q i ve i rsf o ( )

Copy_outlet_inf o C r->striπg_data, sizeof ( r— * >εtring_data ) ); REPLY ( who, r );

_gi ve_f it_record ( ) r

r->valuel = ϋopy_f it_record ( r— >valuel, r— >striπg_data, sizeof ( r— >striπg_data ) ) ; REPLY ( who „ r . :

reset stati

K__.__.t_ L. iti sties (

Who, .' _

decode card ( )

Tr a..__-a__t_ D'". *ts

if < (r->valuel = Card_is_known_to_me( t->TRAC 2 ) > !=

UNKNOWN_CARD ) if ( !Card_has_good_date( t->TRACK2 > ) r->valuel = BAD_DATE_CARD;

REPL ( who, r ) ;

._ρrobe )

Copy_stati sties ( r->string_data, sizeof ( r->strιng_data ) ); r->valuel = Pos_coms_avai lable < ); r->value2 = Poε_info_avai lable ( ); f — >value3 = Requests_avai lable ( ); r- ' .---val e4 = Current_remote__ ti eout ( ); r- '* alueS * = Sequence_nurnber < >

.r->v'alueό = Power_good ( >

REPLY ( who, r ) ;

REPLY( who, r ) ;

*

_open ( )

REPLY ( who , r ) ;

qive me header 1 ( )

COPY_SAFELY( r->strinq_data , Pos_address_l ( ) ); REPLY ( who, r >

_authorize_card ( >

,Poε_requeεt *p; Transaction *t;

t = Decode_tranεaction ( r ); if ( Card_is_known_to_me( t- >TR ACK2 ) != UN.''.NOWN_CARD && Card_haε_qood_date( t->TRACK2 ) S.&

(p = Al loeate_r equest C )) 1= NULL_ REQUEST ) r '

EnqLieue_aut orization_rBque5t ( p, t ) 5 i— >val ue 1 ■= 1 ;

•_

else r — > va 1 u e 1 = 0 ;

REPLY f .-.he... r ) :

_capture_sale )

' _

Pos_request *p; Transaction *t;

t ~ Decode_transactior. ( r );

if ( Emulating ( ) ) r u r->valuel = 1; REPLY( who, r ); return;

f ( Card_ . .is__kπown_to_me( t->TRACK2 ) ** = * = UNKNOWN„CARD )

r->valuel = 0; REPLY( who, r ) ' ; re urn ~

if ( ( p = Allocate_request ( ) ) == * = MULL...REQUEST ) p = Allocate_reserve ( ); if ( p == NULL_REQUEST ) r->valuel * = 0; / * very bad news *

Enqueue_capture_request( p, t ) ; r—>valuel = 1;

REPLY( who, r )

_P t status( )

r->valuel = Emulating ( > ? 1 s Pos_status( ); REPLY< who. r > ;

newpos/bcc_of • c

char Bcc_of ( string ) char *stri ng ;

.r _. chair bcc * = • 0;

while ( *string ) b cc "'"= *stringtt;

return bcc;

newpos/cards. c

#iπclude " Λ d e_r equest . h" ttinclude "types. h"

#de ir.e.:- Ef-iD_SENTINEL '?' #define START_SENTI EL '; '

char *Positiαn_to_start_sentinel < c ) char *c;

for ( ; *c && *c 1= START_SENTI EL; c+t )

return *c ? c s Os

char *p-osition_to_end_εentinel < c ) ch ar *c ; r

for ( ; *c .ϊ§< *c != EMD_SENTI EL; C++ )

return *c ? c _ O:

char *Position_paεt_field_separator ( c ) char *c;

-653-

return *c ? c + 1 : 0;

Normalize_track2( string ) char *string; r

*e,

*P. calc_bcc, cards_bcc;

if ( <s = Poεi tion_to_start_seπtinel ( string > > S.S. (e = Posi tion to_erιd_sentinel ( s ' ) ) . r

cards_bcc = *(e + 1); / * remember the bcc *•

Me + 1) = '\0'; /* string! fy the track #/ cards_bce -= '0 ' ? •' "ur.chr.r " i I- calc_bcc = Bcc_of ( s ) ; if ( calc_bcc .•= '0' ) /* unchar i. tr #/ calc_bcc — = '0 ' ; if ( cards_bcc != calc_bcc ) / * no good card */

C

♦string = ' \0 ' ; r fcLurn ;

- JofeO-

for ( s++, p = string; *s &S-. *s != END_SENTINEL; s+t, p++ )

*p = *s; *p = '\0 ' ;

Cart_r_is_knowπ_to_me( traek2 ) char *track2; r

Fit_iπfo * ,

*Look_up_card ( ) ;

if ( f = Look_uρ_card( track"2 ) ) s itchϋ . f->CARD_CATEGORY ) r "u case it return PETRO_CARD; case 2s return VISA_CARD; case 3; return MASTER_CARD:

**_

return UNKNOWN CARD?

Card_has_good_date( track2 ) char *track2; r

rei:urπ Po≡.-_yyn.ιτ_ ( ) <~ Cards e:*;piry__yyrnι ~ . fr- c k!

newρos/cf i les

accept. c api . c bcc_of . c cards. c decode. c do_work . c dont_know. c encodings. c f irst. c f ree_pool . c host_reply. c 1 ink__tags. c match. c mode. c my_timer . c pos. c pos__control . c pos_i nfo.c pos_status. c power. c queue. c queue_auth. c queue .cap. c queue_tabl e_ c

recd_message.c remoteio.e requests,c restore,c save. c sasct en c . c i> _. =A -- -IT, , C the_dead . c

_ -

newpos/const . h

ttdefine POS PORT 20 ttdefine POS DATA STORE "/dave/poε_data"

'..define MAX FITS 1U '* .. of card types

ttdefine AWAITING_SEND 1 /* states of a request */ ttdefine AWAITING_LINK_REΞPONSE ttdefine AWAITING HOST REPLY

ttdefine FIXED FLOOR LIMIT 7500 /** by edict */

ttdefine AUTH0RI2ATI0N_REQUEST 100 /* message types */ ttdefine AUTHORIZATION_REPLY 110 ttdefine CAPTURE_REQUEST 220 ttdefine CAPTURE_REPLY 230 ttdefir.e TABLE_REQUEST 350 ttde ine OUTLET_TABLE_REDUEST 351 ttdefir.e FIT TABLE REQUEST 352

/* serial line stuff */ ttdefine LINE_TIMED_OUT /# meta character */ ttdefine SOH 0« 01 ttdefine STX 0x02 ttde ine ETX i * ~ r- lef ine LOT 0", I

__- £-£Zf- -.

ttde ine ACK Ox06 ttdefine NAK 0>:15

ttdefine ONE_TENTH ttdefine HALF SECOND 10

/* Authorizati on abort codes «-/

ttdefine LINK_U AVAILABLE /* no "cts" */ ttdefine NO_LINK_RESPONSE /* timeout - no ack or nak ttde ine HOST_TIMEOUT /* no answer from petro Canada ttdefine LINK REFUSAL /* got nakked

/* Client's replies *

ttdef i ne MAKE_ IT_A_POST_PAY "POSTPAY " ttdef i ne " ITSJ-iOT "HOTCARD " ttdef i ne MAKE IT A PRE PAY "VALIDATED"

/* API requests */

ttdefir.e AUTHORIZE_CARD 1000 ttdefine CAPTURE_SALE 1001 ttdefir.e PROBE 1002 ttdefine OPEN 1003 ttdefine DIE 1004 ttdefine STATUS_DF_POS 1005 ttde ine SI E_ME_KEADER_1 1006

#.__ . i.ii I.-»T" X.—- TLJ-r n r-- .a-, ι—. r-- .1 .-..-.—>-

frdefine Y0UR_INF0 1008 ttdefine Y0UR_FIT_REC0RD 1009 ttdefine RESET STATS 1010 ttdefine L0AD_INF0 1011 ttdefine DELETE_FIT 1012 ttdefir.e LOAD ... FIT 10:1.3 ttdefine SET_LINK_TIMEOUT 1014 ttdefir.e CARDS_.EXPIRY_DATE 1015 ttdefine GIVE„QUEUE_ENTRY 1016 ttdefine DISABLE_TRANSMISSION 1017 ttdefine ENABLE_TRANSMISSION 1018 ttdefine SAVE_DATA 1019 ttdefine REGISTERED HYDRO USER 1020

ne pos/decode.c

ttincl ude " -"-d ve_r equest . h " tti ncl ude "types, h "

sta-ti-c Transaction _t%

Transaction *Decode_traπsaction ( r ) request *r; _ zero. S._t, sizeof C _t ) ) 5

_t.AMOUNT = r->value2; λ _t.PRICE = r->value3; _t.PRODUCT ** = r->vaiue4; _t. OLUME = r->value55 _t.CLIENT = r->client; _t.DAVE = r->value6; _t_LANGUAGE__CODE = r->strir.g_dat l- 65 15

— --.. .— _ — —r _ _ r _• _z -1 r \ ,-. . r ..--STll- li.y ucv_.ciL c___ι _ι — \U J

CDPY_SAFELY( _t.TRACK2, r->string_data .5 COPY_SAFELY( _t.AUTH, r->string_data t 60 ) ; Normalize_track2( _t.TRACK2 ); if ( _t.TRACK2C 0 1 == '\0 * > zero. _t.TRACK2, sizeof _t.TRACK2 > ;

-return S. t.ι

rusiriD S ili.' v" >r \ „ c

ttinclude "types. h" ttinclude "const. h"

Do _ war I- ( )

_ ι-O___ r e est '-r r. int essage_waι tings

messε^ge_waιting = Acceρt_meεsage_frorr._remote ( );

if ( (r = Fιrst_auth_awaιting_send ( )) 2.C' Power_good . ) )

\.

-- STATE - AWATTlNC._L..'.i _RLF. CU-iEE? r- EXPIRY TIME = ealnowC . t Current remote timeout < ) ;

__ j. _-l:. . ϊ

if i Transmit-, r ) >

r-. STATE = AWAITING..L INI _ RESPONSE; r - F.XP1RV TJMIr = ~ alnow- ) r υ.- r erd t- i-j.note t J .m-? ut (

else if

( (r = First_table_awaiting_send . )) S.S. Power_good ( ) ) •C if C Transmit ( r ) ) s. i- — .-• -__. I t-i i ϊ_ — HIWHI J. I l .-.._3_ 1 ϊ r—>EXF'IRY TIME * = calnow( ) + Current remote timeout'. ) _

if ( message_waiting >

Process_received_message( . Check_for_request_timeout ( ) ;

newpos/dont_know.

Dont_know_what_to_do( )

newpos/encodings.c

ttinclude "types.h"

Encoded. amount ( U, amount )

unsigned amount5

tsprintf ( b, "7.0-h " , amount ); return 6;

Encoded_trac.2._ b, trac.2 char #b , *tract- 2;

tsprintf < b, "'.02d"/_-40.40s" , strlen ( trac \ 2 ) , trad 7: ) , return 42i|

£ncod _authoricaLi n < b , str1ng > char fc-b„ *string?

memcpy( b, string, 5 ) return 5;

__.i r...i ' * .ι1 _~aI -_ _t.r.i| ui- _ . r .

Transaction *tζ

char *s = p, bufC 4 3;

S-fcrcpyC p, "OOGB" > 5 p t= 4s

p t= Product_detai 1 ( p, t )j p + * = Total _due_detail . p, t );

tsprintf ( buf, '"/.03d", (p - s) - 3 ) 5 /* length sub-field -*/ memcpy. s, buf, 3 );

return p - sj

Product_detail ( p, t ) char * ; Transaction -s-t:.

p +— Encoded_ρroduct__code( p, t—>PRQDUCT ) s p += Eπcoded_quantity< p, t->V0LUME ); p t= Encoded_price < p, t->PRICE > ; p t= Encoded_amouπt < p τ t->AMOUNT ); return 1&;

Total_due_detai1 < p, t > char *p5 Transaction *t|i r x. εtrcpy( p, "95" ) ; p ι= 2; return Encoded_amoun < p, t- AMOUNT ) t 2;

Encoded_c * uantity< p, volume ) char *p; unsigned volume; r

return tsprintf ( p, "7-04u" , volume );

Encoded_prιce . p, price ) char *p; unsigned price;

returr. tsprintf". p, "V.04u" , price 1

-.

Encoded_ρroduct_code ( p, our_code_for_grade ) char *p * ι unsigned our_code_ for_grade?

- 6 *-

switc ( our_code_for_grade )

C case Is their_grade = 2; break; case 2s their_grade = 3; break; case 3_ their_grade = 1; break;

return tsprintf ( p, "XG2d", their_grade );

-61-5-.

newpos/f irst. c

ttinclude "types. h" ttinclude ' const, h"

Pos re. ir--? H int _Sf-r..._ _t--?ιtf * r ' •"•/pe "> unsigned type 5 r

Pos_request *pr,

for ( p = Fιrst_requeεt ( ); p; p = Ne::t_request < p ) > if ( p- STATE =■ * = AWAITJNG_BEND Z>b p- rREQUEST_TYPE == type ) return p;

return NULL REQUEST;

Pos_request *Fιrst_auth_awaι tιng_send ( )

ιrs* se n tl 11 er ( ALU HO R I Z AT ] DM REQUEST )

F"os_ rt_qut &. t -*Fι r _: L _caρture_awaι ti r.g_=end ( )

returr. First send waiter < CAPTURE REQUEST >

I ι i . I ..1

return First_send_waiter < TABLE_REQUEST );

S- r-_

i.ew DE ' -l- ree_.oool . c

ttinclude " ypes.h"

ttdefine NUMBER_OF_NORMAL_ENTRIES 50 ttdefine NUMBER_DF_STANDBY_ENTRIES 2

ttdefine POUL SIZE

static Po___request *_ραol II P00L_3IZE.l,

Inιtιalι__e_request_pool . ) C

Pos_request *r; char *calloc( ) ;

for c i = 0: i ' PΩDL__SIZE; H-t ) _pool C i 1 = <Pos_request "-•-. ealloc . 1, sizeof ( Pos_request i > s

KG- iue- i _■ ' -&11ar..J f

return Deeil locate_request ( Al locate_requeεt . ) )

Pos reuufc. *AU • to rπnuest

r

Pos_request *r; int i j

for ( i = O5 i < NUMBER_OF_NORMAL_ENTRIES; i++ > if < ( r = _poolC i 1 ) != NULL_REQUEST ) r -

_ . pool Z i Ii = NULL_REQUESΪ . return r;

return NULL REQUEST;

Pos_request *Allocate_reserve( ) C

Pos_request * ; int i ;

for C i = NUMBER_DF_NORMAL_ENTRIESj i < P00L_3IZE|i i++ > if . ( r = _pσolE i H ) != NULL_REQUEST ) \r.

_poolC i 3 = NULL_REQUEST? return r;

Log_memory_al1ocation_fai1ure< ) ; return NULL REQUEST; . /* real bad news */

_

Deal 1 αc t t-___req ue _■ •■ _. . r 1

/* always try to return "RESERVE"s first -*/ Pos_request *r;

,r

int i ;

if t r == NULL REQUEST ' >

for < l = POOL. BIZE - Ip i ..'= 0; i— ) if ( _ρoolC i 3 == NULL_REQUEST ) r

..pool C i 3 = r;

.ero( r, sizeof ( *r ) ); return Is

return '..'_

newpos/host_reply.c

ttinclude "types. " ttinclude "const.h"

Process_host_reρly' h )

Host_reply *h; C

Pos_requeεt * ; int msg_type = Reply_type( h->TAG.TYPE >?

if ( msg_type == OUTLET_TABLE_REQUEST )

Update_outlet_info( h->LI _MESSAGE ); return;

_ else if ( msg_type * == FIT_TABLE_REQUEST ) r

Update_ it__table( h->LI :_MESSAGE > Ϊ return;

else /* it's a real reply */

if ( p = Match_host_reply( h ) ) switch'. msg_type )

case AUTHORIZATION REPLY

Process_authorization_reply( h, p );

* breaks

* case CAPTURE_REPLYs

Process_capture_repl y( h, p ); brea,'!!

else

Log_unsolicιted_host_ epl ( / ;

Process_authorization_reρly( h, p ) Host_reply *h; Pos_request -p;

nt ans er

Dequeue_request ( p ) ; answer — Tel 1 _ιτ.y el \ e L . p- CLTFNT, h- .IN. MESSAGE )

L oq_au ι"hor"iza _ on rep. 1 , v ( p , answer . .

Deal 1oc«_ιte_request . p )

Tel1_rr.y_cllent ( who, what ) Tid who; char *what;

*r = Repl s_resρonεe_code ( what ) , 1 = Replys_language_code( what );

if ( strlen ( what ) < 52 ) answer = MA E_IT_A_POST_PAY; else if ( Authorized ( r ■, "> ) answer = MAKE_IT_A_ PRE PAYs el se i t C .τιe>τ>cfi.pt '■. r » !* u4 '' . . ' __ — — u ) answer = ITS_HOT_; else answer = MA E_IT_A_POST_PAY * t

Send_reply_to_cli πt ( who, answer, a, r, 1 );

return strcmp ( answer, MA.-.E_IT_A__PRE_PAY ) ~ 0;

Send_repl _to_client ( who, answer. autn_πumber , reεponse_code, language ) Tid who; char -K-answer , *auth_πumber _■ *resρonse_code, language;

static char _clieπts_ . messageC 50 l r,

zero. _cl ients_.τιessage, sizeof ( _ci ien s_.message ) ) ; tsprintf ( _clients_.τ.essage, "7.9.9s7.5.5s"/£2.2s"/.c" , answer, auth_number , response_code, language ); os_event C who, __clients_message ) j

Aut r i z ed ( r , a > char *r, *a|-

,r

if ( (memcmp ( r, "00", 2 ) == 0) ...- memcmp ( a, "00000", 5 )

!= 0 ) return 1 r.

e u n υ;

Process_capture_reply ( h, p ) Host_reply *h; Pos__request *p;

*_

1+ ( Capture__request_sat. sfιed v h 1 >

Dequeue_request . p > ; Log_capture_repiy( p ); Ueallocate. . request . p )

Capture_request_satisf led ( h ) Ho"it__re-pl v *h ;

return memcmp ( Replys_response_code( h->LIN _MESSAGE ) ,

"00", 2 ) — 0;

char Reρlys_laπguage_code< r ) char * s -'_ return *(r + 42) ;

char *Replys_auth_code < r > char *r;

return r + 43; * .skip Lhi <__n αusoe __> i _. *

char -sRe ly3_resρorιse_code ( r ) char *r;

-633-

ne pos/1 in _tags. c

ttinclude "types. h" ttinclude "const. h"

'- ~::: ' t Z- lr, a .tag* 1" , '". I t--ι. " , rt_.r_i--.es _ L«ρe "> char p.:t_tyρe; unsigned request_type; r

t-.--PAC ET_TYPE = p..t_type; rr.emcp- < t- ' -'TYPE, Request_type . request_type ) , sireof ( Message_tyoe . > memcpy <■ — ≤EDUEMC-i " - , Me,'t_sequence ( - ., =ι_rer.f ' Hsequeπce . ) .

Equal __] ιr.1 _ tag"-" ( tl, t2 "• r _

LI t . Ξ 1 Cj I i C" Cl _. . (_.__ . > tyρe2;

typel = Replv_type( ti- TYPE > ; type2 = Reply_type. t2- TYPE );

\ . ' ,. • \ I I I I |. I t- II

Ill- lfi lϊli i < t J M-.-i. "1 IF i'l. L

-€*< *

Tag_matches_request< p, t > Pαs_request *p;

Link_tag *t;

unsigned tags_type, tyρeε_match;

tags_type = Reply_type( t->TYPE ) ;

switchC p->REDUEST_TYPE >

.r ι_ case AUTHORIZATION_REQUEST. types_match = tags_type == AUTHORIZ TION_REPLY ' ; break case CAPTURE_REQUESTι types_match = tags_type == CAPTURE_REPLY; break de au.lt: types match = Oϊ break

return types_match * .-. memcm < p->TAG.SEQUENCE, t->SEQUENCE, sizeof ( Asequence ) ) == 0 !_... p->TAB.LINE == t->LINE;

newpos/makef i le

CFLAGS = ~-S +Wc . +u SOURCE., = tϋcf j lei

_'. b_l _r. 1 '_• - •____'_. i !-•■-' -z.

pos: -K OBJECTS) linkobj c=ρos i{=objects ιτ.=ρo _ map 1=/user/steve/dave sort pos- ap f=l,2 tr copy pos /dave/pos

newpos/match.c

-{.include "types.h" ftinclLide "const,h"

/* 1. a queue entry matches a link response if and only if the sequence numbers agree and the queue sπtrv is in "awaiting link response" state

*/

Pos_request *Match_link_response( 1 >

Link_reεponse *1 ; ..

Pos_request *p;

for ( p = Fi st_request . ) ; p? p = Neκt_request ( p ) .

if ( p->REQUEST_TYPE == CAPTURE_REQUE3T &&

Equal_link_tags. ?.p->TAB, _a->TAB ) &!_. p->STATE != ** AWAITINB_SEND ) return p?

IT . p— .---CJ . t-i i t :— HWHI I iivi ! _ι_ j. I Γ.._KCOΓ Us'lab. continue? if ( Equal_link_tag . S.p->TAB, ?./.l->TAB ) ) retLtrn p;

turn Nl r.__.i-.L.__.

/* 2. a queue entry matches a reply if and only if the sequence numbers agree and the queue entry is in "awaiting reply" state

Po___request •κ-liatch_host_repiy ( h ) Host...reply *h; r

Pos_request *p;

for ( p = First_request ( ); p; p = Ne;;t_request ( p ) ) r \. if ( P---BTATE • = AW ITI G__H09T._REPLY ) continue; if ( Tag_ιτ.atches_roqLiest ( p, &h— TA6 ) ) return p;

1" ' . . I. " ι " ι rM.l'ULi-

-£W-

newpos/ ode. c

static unsigned _the_mode;

S-_t real mode.

the mode = 1;

Set_dummy_mode < )

the mode * = 0;

Einul atinq ( )

return the

newρos/my_ti er.c

ttinclude <timer.h>

* static Ltnsigned ti er_.rur.rii ng , r. . port;

Set_tιmer _port . port > un s i g n ed p or 15 r

my_port = port;

Reset_my_ timer . )

timer ruπninq =

Cancel _n.-_tι mer (

. Li nιt_r I * . ' 1111 1 _ — i

. 1 u'i r i-'EΪ' AMLCL .1.. lorr ) timer rur.n in

Set_my_tι mer < ticks ) unsigned ticls;

r-iTn. l ιϊi-

set_timer( TIMER_SIGNAL, RELATIVE, ticks, 0, my_port ); timer_ruπning = 1;

Delay( ticks ) unsigned ticks; r c

Cancel_my_tiπ.er < ) 5 set_timer( TΪMER_WAKEUP, RELATIVE, ticks );

newpos/objects

accept. o a i . o bce_ f . α c rds. o decode. o do_worl.. o dont_ now. o encodings. o first. o f ree_pool . host_reρl y. o 1 i n.'_ tags, o match. o mode. o rn/_tι er . o poc - c> pos_cαntroi . o pos_ι n . pαs_statLts_ o power . o queue. o queue_auth. o

queuf.tύ LK

- -

recd_message.o remoteio.o requests.o restore.o sav .o

t ' h-_r dead.o

- 635 —

newpos/pos. c

ttinclude " Λ dave_r equest . h" ttinclude "types. h" ftinclude "const. h" ttinclude stdio.h ^include -..setjmp.h

ttdefine USAGE 1 ttdefine NO_TIME 2 ttdefine M0_DEVICE 3

static j p_buf * .nιtιal_crap;

int argc; char -K-arg L 3 ; ϊ

1. rt - S __ i r - J request r.

if ( code = set jmp . in i ti a ...trap ) )

Ini ti al__error ( code ) ; el se l r. i t i _'] i r i ■ i f-ror , -'i"_ι . ' ",

-£3ι+

task = RECEIVE_ANY< ?.r ); if ( (task » S) == POS_PORT ) r

Reset_my_timer ( ) ; Do. work ( ) 5 s

else

Service_cl ient ( task, ξ.r ) ; Set_my_timer < HALF_SECOND ) ; Maintain_ρos_status ( ) ;

lπιti_tlιiB( argc, __.rgv / int argc; char *argvC3; r _ iog_pσε. "start" :; i '.arqc ! = * 4 §.__ argc I = 5)

1ong imp ( initial_t a , USABE ) ;

if . attach ( POS_PORT ) 1= 0 ) longjmp initial_tra , N0_TIMER );

3et._.Tiy_iine ( arαvC 3 1 v, a ■__rea x ___ ode . ' * :,- tse>__poI*'Gr_stat>...- •? . .'. ' .

- SS -

i f ( argc == 5 )

Set_dummy_mode< ) ;

Reset_message_buffer _ ) ;

InitialiΞe_request._pαol . );

Initi a1 i ze_queue ■' ) ;

Xn1 1aiιze_staL_.'. * > 1cΞ < 1 _.

Set_remote_ti meoLit ( atoi ( argvC 2 II > ) ;

Restore_al 1 . ) ;

Open_remote< argvC 1 ], initial_trap , N0_DEVICE );

Set_timer_pσrt < POS_PORT )y

Erιqueue_tabl e_request ( ) ;

Set_my_ti mer ( 1 1 5

1 og _p os ( " r ead y " » 5

Initial_error ( code ) unsigned code;

ch 3 r essage .

switch ( code )

case M0_TΪMER: message = "no timer port"; break; case NO . DEVICE- message = "no device"; break;

__a-_._ I '•_•!'.i-Ε _ I ■ _■-.•jt.' i ., r • . I- , I . •

break;

log_pos( message ); e.ιit( 1 ) ;

tfprintf ( stderr , "pos device link timeout line no\π" )

newpos/pos.map

.Segment: 1 0000 to 4153 (16724 bytes) .Segment:2 0000 to 042C (1069 bytes) -Segments 3 042D to 09SF (1379 bytes) .Total ≤no is 4AE.4 ',19172 ) bv-.es

COl 0053 prologue

COl 005E epilogue

COl 0067 stk_overflo

Cυl 00S3 £ucbeg

COi 0084 - Αccept_message_frofϊι_r emote

*_

Reset _message_bu fer S t or e_r ec ei v- * ?d_char act er Calcul at ed_bcc Recei ed_bcc rhe_me saq I lessaøi _. recc-i ved Is__3tsi" t _c>r_ιTtessage CBΓ v'l et. cii on _. Val ιd_cl l ent _regι ster_hydro_user _set_pαwer _save_ d ta _L|1 I . , I . i-

£S8-

COl 0414 '._cards_d te

COl 0453 ._load_in o>

COl 047C __1oad_ it_record>

COl 0 AE C_give_info>

COl 04DB ϋ_give_fit_record>

COi ._reset_ . stats>

COi-- ._decode_card>

COϊ: 059A ϋ_probe>

COl 060F :_die Ol 062E C_o en>

COl 0662 :i_gi e_rne_header_l>

COl: 0693 i_authorize_card> c i 0711 __capture_sale> oi 07D1 __ D5_5tatUS> co:ι 0806 Bce_of > c i 032F .iPositioπ_to_εtart_seπtinel > coi 0865 :Pαsition_to_eπd_sentinel > oi 0S9B .Position_ρast_fie1d_seρarator CO 00D4 iNQr alize_track2> COl 097E iCard_i 5_L::πo.-'n_to_irie> COl 09CC iCard_has_qcOd_dat > CO1 09F0 iDecode_tr nsacti on > COl OAAC iDo_work> COl 0BA9 iDor.t_know_wbat_to_.do> CO1 0BB3 :Encoded_amount > COl ■. ' i_-D__: .En c. o d e d _ t r a c k 2 > COi DFB iEr.code-l authori zati. on ': -

-633-

COl OC1A <Encσded_sales_capture>

COl 0C8A <Prαduct_detai 1 >

COl 0CE6 -.Total _due_detai 1 >

COl 0D14 : iEncoded_guanti ty >

CO 1 0D3 iEncoded_pricei--

CO 1 0D4C :. En c od ed _ρ r od uc. t _c od e i -

CO! 0D9C <Fi rst_send_wai ter >

CO 1 ODES •.First_auth_awai tinq__ser.d>

COl ODFB <First_capture_awai ting_send>

COl OE11 : .Fi rst_tabl e_awai t i ng_send >

COl 0E27 < Ini ti al ize_reguest_ρool >

CO 1 0E60 : 'i Reguest s_avai 1 ablei- :

CO 1 0E76 •:. Al 1 αcate_r equest ' :-

CO L 0EC4 ; . ' A1 locate, reserve;

COl OF 15 : iDeal lDcate_reqLiest

CO 1 OF7S .Process_l-ιαst_replyi.

COl 1 '. Pr oce^s_ ιuth l :: at i orι__rep1 •/ ' --

C i 1 ' " > i f j. J. __ it. ι .... _ I t_l ..

COl LOFά- •. &end_rep i y_. to_c I J. er. fc

COl 1 J " ' ■ I'-'iuth r lied ' -

COl 1179 • Pr σcεss_capture_repl y ."

COl 11 BO •i Cap ture_req ues t_sati sf ied>

COi 11E2 :iRepl ys_l anguage_codei'-

CO 1 11 F7 iRepl ys_auth . _code ' -

CO l I _ -. - I 'OU I * ' - I c'Si.' l . '... ..•_.'

C i

^~ oo

COl 1268 <Equal_link_tags>

COl 12D5 <Tag_mat ches_r equest

COl 1376 <Match_link_.response>

COi 13F9 <fiatch_host_reply

COl 1447 <Set real iτιθde>

<Errιulatiπg>

< Set _t i mer_por t > <Reset_my_t i mer > -.'Cancel _my_ti mer > < Set_my_t i mer <Delay>

< Initial ize>

< I n i t i al _er r or > < Usage >

<Shutdown_pos> <Qut1et_in-formationi

•. rt 1 _. sl 'le .- Pαs_ d dress.1 <Set_outl et_i r.-Fo>

< Set _f i t _r ecor d >

< Cop y _out 1 et _ i nf o >

< Copy_f i t_r ecor d >

'■. Pos . i nt o__ aval 1 a l e .

-- " P s vy lϊiiTi ._- : - i Ό™ t. j. iTioo T o

<Cards_expiry_yymm>

<Look_up_card>

<Fit_expiry_date>

<Set_my_l ine>

<l y_linei.-

upda --: .PUL.! ,-'r_ _ .■ ' ■_.

::iUpdate_-fi t_tabl . : Decode_and_load_-fit_record>

<Set_asci i_-field>

<f ake_into_εtrings

<Ne;;t_seρarator> <Poε_status>

<Maintain_.pos..status> Se t _p o er _ st at us -. Power _g ood > Regist r ... h y d r _usε r '• '• ' Tel 1..hydrc'. Liters - : '. Ini i l ιπe_ g e u e . b. r i η u e u _. _r£-quesl <Dequeue_r equest ' <Firεt_request > <Ne.:t_r equest U : EnqueuB. author x __ at i on_.request . 1 Hf IJl ll _( .'.. , '. I I _ I I r i t I'll ■ " ' > .Ji f| ..' L I I f 111 • -' lJ . ' I ..f l i (li v _ , _ I I i i , . >• [

COl 1FF7 <Eneode_capture_link_ essage>

COl 20A5 <Enqueue_table_request>

COi 210F <Ericode_table_request_link_rrιessagei:

COl 2167 <Process_received_message>

COl 21BF <Pi-ocess_lirik_response>

CO L 2220 PDS1tive . ..1ink .response)

COl 227B <Megative_link_response>

C-01 22D1 <Purge_queues>

COl 2301 <All_purpose_nak>

COl 2339 <Open_remote>

COl 2339 <3et_re ote_ti eout>

<Current_remote_timeout>

< Reιτtote_avai 1 ab 1 e_πo >

< Cl ose_r mote > <Transmi t> < Next char > < Req uest _t y p e >

< Rep 1 y _ t y * ρ e > <Res o e_al 1

COi 2601 <Save_al l --

C01 27A9 <Ne>.t_sequence>

COl 27DC <Set_sequeπce_number>

C01 27EC <Sequence_πumber>

COi 27FB -.Initial ize_statistics>

C01 231D <Reset .statisties ' "-

COi _c&4 _ -- ' i ne. -_r_ ..ft -z - 0.L ' __5_.__ι--i -i .u-. ιl.-.t.i:t:ic;.

_^os_

COl 2S7D <Lαg_remote_unavai1 ble COl 288E <Compute_oldest_capture> COl 2924 <Log_queued_c pture> COl 2935 <Log_queued_authori _zation> COi 294& •• •iLog.1ink_timeout> C i 2 l_i " ' ..LoQ_abort d_auti.or.__.'.j Ior..

COi 299D <Log_link_re*fusal >

COl 2 E <Log_hαst_ti eout>

COl 29BF <Log_unsolicited_link_responsei

CO1 29D0 <Log_unsαlicited_host_reply>

COl 29E1 <Log_authorination_reply>

COl 2 S9 <Log_capture_reply>

COl 2B1 rc_error>

COl 2B2B Log_memory_al 1ocation_*fai1 ura.-

CO1 2B3C <Check_tor_request_timeout i'

CO1 2BE5 ■■ ' .Timeout_tab1e_requeεti' :

COl 2C01 iTimeout_authorization._request "

C 1 2C3F - •' Ahort. authoricat. o.. request '-

COi 2CDL --.po_r_event.•

CO] in •■ •i er.,e -Jent.-'

COl 2D03 ='.log_po=.

COJ. 2D1C event. '

CO1 2D 5 1request

CO1 2DBD <Address_o*f

CO', 2fH."--' i.di .." i

COi ..DC:.'

~"*Ol4-

CCH 2FFA .calmthlen cc*r 3027 .calnow>

COl 30D6 .cal work> COl 31CD _calsplit>

COl 34B1 !calwkday>

<-, -•_! . si-.. _ eal t i sT.ez one . ;_calcsecs> idisallow> imy_oρen> i lee > iabs_sleep iset_timer> _ st ncpy ϋs- Cstrπcati--

_o: '. strncmp > iset_attr> .set_opti n >

.get_opti on > idregi ster_namei

: ind_admiπ

_ char _wai t i ng

:icalloc> imsl 1 oc > 'real 1 oe

COl 3DEE <memchr

COl 3E1B <memccpy>

COi 3E56 1epilogue

COl 3E5F lmul

COl 3EAE l odr

l divr

<vc_send_reply>

< vc_cr eat e

<vc_create2

<vc_create3

<ker_vc_destroy * i <dei-_5erver> <set_acc_ 1 gs>

<set_exception> <escape_tty> <hold> <unhold> <time_siice> <task_ . in-Fo>

<force_ready>

< se t _p r i or i t y > <set_user >

- ■ mod ÷ v f 1 acfs ' -

COl 3FF1 ••set_int_vec

COl 3FF7 -.:allαc_me * n

COl 3FFD ,get_date

COl 4009 get_tιc. s

COl 4015 reply

COl 40IB attach

COl 4021 detach

COl 4027 -.awaits

COl 402D signal

COl 4033 .read_msg.

COi 4039 wrιte_msg

COl 403F ,read__port

cυ rr-j a _ L. i

- ?og -

DO OOOO <User_sp>

DOO 0002 User_ss>

DOO 0004 <Exc_bits>

DOO 0008 <E;:c_al1ow>

DOO OOOC <Eκc_pending>

DOOO 00lO <Exe_tp>

D00-- 00i <E * -- * c_pc>

DOO 0014 <E.c_permit>

DOO 0018 <E;-.it_status>

DOO 001A Error_statusϋ

DOO 001 <My_tid>

DOO 001E <Dads_tid>

DOO O020 <Break_count>

DOO 0021 <My_tty>

DOO 0022 stac _base

DOO 0024 <CιTιd_tlags>

DOO 0025 <My_priority>

DOO 0026 <stdiπ

DOO 0028 <εtdout>

DOO 002A < ' st_lsrr>

DOO 002C <Free_list>

DOO 002E <End_o*F_tree>

DOO 0030 <Fi1e_1ist>

DOO 0032 <_Argc>

DOO 0034 Arqv

DOO K i l .-iil

DOO >036 SAVE

-^Oq-

DOO 0038 TEMP

DOO 0060 Code_f lags -

DOO 0061 "User_num i

DOO 0062 Brouρ_num

DOO 0063 Tea _nurι

DOO Oθ67 > Dads_n d

DOO 00<_>9 My_tty_md

DOO 006B - My_cd_nιd

DOO 006D - Rel ease_πuπ..-

DOO 006E •■ ..r•. p_save_area -

DOO 0070 Fstac.

DOO 0072 Call_s acl __ptr

DOO 0074 _-.egmeπt_t abl e_ptr

DOO υ07 Checl _poιnt_sp

DOO 0073 User_spare

DOO 007E Ddb_tιd

DO-; 07F.-D 1.1 j II E'

DOZ 05ECJ

- 1 10-

newpos/pos_control.c

#include "const.h"

Shutdowπ_pos( )

.r

Cl ose_reιTιote ( ) ; detach . PQS_PORT ) ; Save_al 1 ( ) ; ex i t ( ) :

~ ?Aλ-

ne pos/pos_in-f o. c

#include "types. h" ttinclude "const. h"

stati r Uu l<?t ιr.-?r. M÷.

IC Fit l r.τ o Fi t f 11.1 X FI TS 3

Outlet in-fo *Outlet m-for ation < )

return Me;

unsigned *5i * :e,

*SI:E. = sizeo-f ( _Fιt ; ; return Fit;

.1 i ir -r _.<=- πddress L . >

retur n Me. ADDRESS1 ;

Set_outl t_ιn-fo ( l )

Ou let * , n-ro s-i * ,

Me = *i ;

Set_*f it_record ( n , •" ) unsigned n; Fit_in*fo *f;

i-f ( n >= MAX_FΣTS ) return ; else memcpy ( _Fit + n, -f , sizeof . Fit_info ) ) ;

Ce.pγ_outlet_in-fo ( b, len ) char *b; ini ' ! * =r.

memcpy t b M_ 1 en sizeo-f ( Me ) ler sizeot ) ) ;

l_.a_ ) __ y T j. ι_ . __.__ _..r :.j

cπ r *b ; int len;

if ( π < MAX FITS )

•>ifc.|i.:._!..' y ' "... , r j > -i- ..

-~ _-~

len sizeof < Fιt_ιnfo ) len sizeof < Fit m-fo ) ) return 1;

return 0:

return _FιtC 0 _J.CARD_FF.EFIXC 0 1 - ' \0 Me. DDRESSIC 0 1 ' - ' \0 ' ;

Pos_yym . )

mt y-f 5 mth . day, hr, m , sec ,

c "i sμ 11 t ' ca . , -vr" , ■""n't 11 "-da -■ . Z'hc _, ?/Ϊ ~± r. - ..sec )

'.'i- — I 9ϋU 1 return yr * 10t ") t mth;

os tiineoid for . trac 1 )

Fit_inf-o *-f ,

*Look_up_card < > 5 i-f i -f — Look_up_card ( track2 ) ) return f->TIMEDUT;

Cards_eκpiry-_yymm ( traek2 > char *track2;

Fit_info *-f ,

*Look_uρ_card ( ) ;

f = Look_up_card < track2 ) ϊ return Fit exDiry date < -f 5 track ' 2 )

. iiTU -=-!__.". _ _uρ_ι_ar d •' dat )

L-. ic.r - y -i-i I

111 C I S

Fit into *-f Fit;

~7-Λ SΓ- f σr < i = 0; 1 MAX_FITS; i tt . -f++ ) if < memcmp < data, f-i'CARD_PREFI , strlen < f->CARD_PREFI ) ) * = * = 0 ) return ;

return 0;

it_e>-ρiry_date ', -f , data ) Fιt_info -x-f ; char *data *

char bufferC 5 3 u int i .;

if ( f == 0 ) return ;

if ( f-. EXPIRY DATE RELATIVE == O ) /* use -fi.ced */

E'. DATE XED

.1se

for ( i = Os ~ , - EXPIRY_DATE_RELATIVE; I ++ . data = Pos Ltior._past__fιeld_separator ( data i ;

sero bu er, sizeof . buffer ) ); memcpy( buffer, data, 4 ); return atoi ( buffer ) ;

char *s;

IIIV ine = *s;

char My line )

Updc_.tt_-__.jut1fc_t_intLj C in ) char *m;

char *ϋet_ascι i ' -i ai d ( ) %

i '-. strlen ( ) -. 160 ) returnp

Make_into_string '. ) i * m = Bet aεeii field , , Me..OUTLET NAME. l e.. n;jTLE " NAMF

sizeof ( _Me.ADDRESSl ) > = Set_ascii_ iel < , _Me.ADDRESS2, sizeof < _Me.ADDRESS2 ) > ; rn = Set_ascii_fiel ( , _Me. PROVINCE, sizeo ( _Me.PROVINCE ) , ; rn = Set asc. _f i el < m. _Me. POSTAL .CODE. sizeof ( _Me„ POSTAL_.l UDf_- ) > •• m = Set_ascιι_fiel < n. _Me.TELEPHONE, sizeof . _Me. TELEPHONE ' )? = Set_asci i_. iel . m, _Me.SERVICE_STATION_NUMBER„ sizeof . _Me.SERVICE_STATION_NUMBER ) ); = * Set_ascii_ ield , _Me. PROVINCE_NUMBER, sizeof ( _Me.PROVINCE_NUMBER 1 ■ 5 rn ~ Set_ascιι_field( m, _Me„OUTLET_NUMBER„ s zeo-f . _M „ OUTLET..NUMBER ) ■ > . m = Set_ascii_+ιeld< m, _Me. DEVICE_NUMBER, sizeof ( _Me. DEVICE..NUMBER ) > 3 rr. ■= Set_asc11_ ie1d .1., _Me. SECURITY_CODE n

Uρdate_f11__table . ...

*> char *m ~

I . I''

ι

Fit info *f = Fits

if . 1 < 42 ! ! < 1 7. 42 ) != 0 ) return;

AT , r (_. '_'_'! US .• - riι-tΛ_r i I c. .' records * = * MAX_FITS;

zero-' _Fit, sizeof ( _Fit ) ) ; Make_iπto_strings< ); for ( i = O; i < records; i++, +~ 42, ftt ) Decode_and_load_fit_record ( , f ) ;

i?ecode_ar;d_load__i*it_record ( m, f ) char *ιn- Fit_info * ;

Set_ascii_field< rn, f->CARD_PREFIX , sizeof ( f->CARD_PREFIX ) );

for ( p = * f->CARD PREFIX; *o .?.?. *p. i= ' ' % p++

X f ( * p -== ' ' ) *p = '\0

m += 6 ; f- TIMEOUT = atoi < ); t= ;

T- LC' _r L A __. :- _.ιt J t ... ' , nl t= 3,', f--ACCT_FIXED_LEMGTH = atoi ( m > rs m t= » f-. EXPIRY_DATE_RELATIVE = atoi ( m ) ; m += ; f-.EXPIRY_DATE_FIXED = atoi . m ); c = * (m + 21 > ; - CARD CATEGORY = c - 'O's

char *3et_ascι i__fleld ( data, buf, len ) char *data, *buF,, *1en; r \ if ■ rr rttft -- ECU >

* ero I bu-t , len . ? _* for ( — len ; * ata -'". len * len — . *buftt = rrdata+t;

r tL.i r. ot ,, , 1 1 ;

{

I!

Ul itl XI fl!

"1 fll rt-

0

- * 'i

i

newDQs/pϋs. status. c

Pos_status( )

return Pos_info_avaιlable( > hh Pσs_coms__avaιlable . ) hh Request ** _avai l blel hh Power_good ( ) :

stat-C int _tr -_counter ,

Maιntaιn_pos_status( )

/* one hit in 10 seconds means things o. */ r

iτ ( _trs._counter * = **■* 20 )

_lr _countf_ , r = O"

i i _countertt ; i -a. c-l _ 1 Θ a J π .J i ',

uts ι__jnιτ> a al 1 aDi eι )

return _hιts t Re.Tιθte_avaι 1 abl e_now ( 1;

/* in case ne lust r set -

newpos/pQwer. c

ttdefine M X_USERS 10

static unsigned _power;

/* we could be in a power down situation *

Set_power_stattis( up ? ur.-signed up.

_power ** ** upi;

Power qood C )

return DO er:

umsiαned user'. MAX USERS 3:

Reqister hvdro user C num, atask unsioned πurn. atasι-.?

nu —5

Tell hydro users. )

- - -

--HI-

for < i = 0; i < MAX JSERS ; i++ ) - if ( userC i 1 == 0 > continue; power. . .event ( userC i 3, _power ? "P0WER_.B00D" :

"POWER FAIL." ) ;:

newpos/queue.e

#incl de "types.h"

static Poε_request dummy: static Pαs__request e_toρ ,

Initialize_queue ( )

.top * =*ξ. dummy5

_bottαm = h. dummy;

Enqueue_request ( r )

F'os_request *r; r

_bottom->NEXT = r; r—>PREV = _bot orπ; -. •_ ~ |i i r_-.r~ -—,i π— .— -.-r- r — ..• !'.__. Λ I — i Ul_l__rϊ. __.:. !■ - - .__. ' bottcuTi = r ;

Dequeue_request ( r ) Pos_request *r;

reαuest *π

p = f—>PREV; n = r->NEXT; p->NEXT = n; if ( n ) r.->PREV = p.; elsε

_botto.τ. = pj

Poε_requeεt *First_request ( )

return _top->NEXT;

Pos_request *Next_request ( r ) Pos_request *r;

return r—>NEXT;

-1Z&-

newpos/queue_auth. c

#include " Λ dave_request.h" ftinclude "types. h" ttinclude "const. h"

Enqx.ieue_authorj.zati oπ_request i p) τ_ Pos_request *p; Transaction *t;

char *Neκt_sequence( );

p->CLIENT = t->CLIENT; p->TRY_COUNTΞR = 0; p->STATE = AW ITIMG SEND; p->TIMEOUT — F'os_tι.τ.eo p->CREAT10!M_TIME — eal no . ) ; p->EXPIRV ' _TIME = p->CREATIDN_TIME t Cuι-rent_remote_ti meout ( ->REQUEST_TYPE — AUTHORIZATION REQUEST;

_-.ncode_auth_l i r.k_nιessage p ,

Enqueue_request p ) ; Log_queued_authorizat1oπ C ) ;

Eucode__auth_l ink message . p, t )

.r

char *c = p->LIN _MEBSAGE;

i < t-> MOUNT == 0 ) t->AMOUNT = FIXED_FLOOR_LIMITp

Sftt _iir... _tan . ..p-WAG, SON,, AU HO I_AT1ON REGUES1 )ϋ zero( p- LINK_ME3SAGE, sizeof ( Lιnl._message > ) ; c = Encoded_amount ( c, t->AMOUNT ) ; c t= Encoded_track2( c, t->TRACK2 );

*c+t = EOT; p->BCC = Bcc_of ( S.p->TAG ) ;

i.

9

Λ

— ?2o —

ne pos/queue_ca .c

ttincl de " Λ dave_request.h" ttinclude "types.h" ttinclude "const.h"

--.rquet-ie. capture request . ■, t ) Pαs_request *p " ; Transaction *tρ r

char *Next_sequeπce( > ;

p->CLIENT = t->CLIENT; p->TRY_COUNTE ' R = Op p->STATE = AWAIT1NS_SEND; p->CREATΣON_TIME = calno C ) r, p->EXPIRY_TIME = OL; p->REQUEST_TYPE = CAPTURE_REQUEST;

.ud. _capture_l

Enqueue_request p > ; Log_queued_caρture . 5

Encode_capture_l i nk_message ( p , t > Pαε._request *p ;

- . -

char *c = p->LINK_MESS GE;

Set_lin.._tag < ,.p->TAG, SOH, CAPTURE_REQUEST ); zero< p->LIN _MESS GE, sizeof ( p->LI _MESS GE ) ); c +- Encoded_amount ( c, t->AMOUNT ) ; c t= Encoded_track2( c, t->TPACK2 > ~

* c ++ = t->LANGUAGE_CQDE; c t= Encoded_authorization ( c, t—>AUTH ); c t= Encoded_sales , _capture . c, t ) ;

*c++ = EOT; p->BCC = Bcc_of ( S.p->TAG );

πewpos/queue_table. c frirrcl ude " Λ dave_request . h " ^include "types. h" #include "const. h"

Enqueue_tabl e_r equest ( .

Poε_r quest *P5

p = AlIocate_request . ) ?

p->CLIENT * - *** 0; p->TRY_COUNTER ** ** 0; p- ST TE = AWAITINB__3END; p->EXPIRY_TIME = OL; p->REQUEST_TYPE = TABLE_REQUEST;

Eπcode_table_request_link_messag ( p );

Enqueu.e_requeεt ( p ) ;

i ι_.u t__tι_ιLι i tr_ -?q u __.__. t_l x r k_ iiit. __■-=_• ay Pos_request *p ; r

char *c = p->LINK_MESSAGE;

a. an

Ξernl D->L D~> lN l-. L~ SS. " ) )

-73Λ-

*c++ =. EOT; p->BCC = Bcc_of ( _.p->TAG ) ;

newpos/recd_message. c

ttinclude "types. " ttinclude "const. h"

\ r. char *-ιTι ,

*The_fnessage C ) ;

if C Calculated_bcc( ) != Received_bcc ( ) ) r

Log_lrc_error ( ) ;

Reset messaqe buffer ( ) ;

m = The message ( ) ;

case NAKs Process_link_resρonse < m ) 5 break; case SQH: Process_hαst_reply( ); break;

Reset messaqe buf --- ( ) s

Process_lin _response( 1 )

Link_response *1 ;

*C

Pos_r equest *r;

if • Λl 1 _ pi tr Do e_.n < ] 1 > else if ( r = Match_l m.-_respoπse < 1 ) > switch! I---TAG.PAC.:ET_TYPE Ϊ

case ACK: Positive_lin _response( r ) ; break; case NAK: Negative_lin. _response( r ); break;

else

_ur.soi3C3 ted_lιnl _response.

/ * fi.ar. request reply pending */

Pos _ 11.___.. i . response ( r ) Pos_request %r :, r

i— STATE = AWAIT1N6_HDST_REPLY; if < r- REDUEST_TYPE == AUTHORIZATION_REQUEST ) r-i-EXPIRY TIME = calno ( > + r- TIMEOUT t Current remote timeout ( )

[ in ,, 11 i . _.f I .-. r . re iile-

Lli i e.-iue__t ., en<= L L ι e11

Negati e_link_response( r >

Pos_request *r;

switch ( r->REDUEST_TYPE > r

ease CAPTURE_RE UEST:

Log_link_refusal ( ); r->3T TE = AW ITI.-.G_SEND; r- EXPIRY_TIME = OL; break; case AUTHQRIZATION_REQUESTs

Abort_authorization_request ( r, LI ki_REFUSAL ); break;

/* disaster has befallen the pos link

r rpfa; UUKUBSI

Pos_request *r;

for ( r -= Firεt_requeεt ( > r; r = Ne:ct_request ( r ) ) Neα tive link response ( r );

All_purpose_na < 1 ) Link_response *1 ;

.r return 1-XTAG.PACKET_TYPE == NAK hh. memcmp ( 1- TAG.TYPE,

"OOOO" , 4 ) == 0;

_

newpos/remoteio.c

#include "const.h"

#iπclude "types.h"

#iπclude <stdio.h> ttir.ci ds .setj p.h. ' -'-

static FILE *pos_in,

s- os_out5

static unsigned io_port;

Opeπ_remαte ( device_πame, trap, error ) char -x-device_πaπ.e; int error;

disallo ( ) ; ρos_iπ = ir.y_oρeπ •-. devιce_naπie, "rv ., trap, error ) ;

f I ush_inρut . pos. in ) ; io_ρort = Address of . ρo-=_ i n ) »

static int sees;

Set remote timeout ( sees )

sees — sees;

Current remote timeout ( )

return εecΞ;

ttdefine DCD 0x0080 ttdefine DSR 0>ι0020 ttdefine M3R 6

Remαte_avaιlable_no ( ) /* determined by 8250 Data Carrier Detect * r

return . ιo_ιn< .o_port t SR ) h DSR ) " " ' 1 s -

Close remote ( )

. close i pαs_in ' r, fclose( os_out J II

Transmit ( r )

# Pos_request *r

TPY_C0UMTERttq

I Kt'itlO t L. n '..', . I ili.J . i I l l-l '

-?3S-

f ut( h.t — >TAG, strlen < hr — >TAG ) , pos_out ); f ut . ../.r->BCC, 1, pos_out ); return 1;

Log_re.τιote_unavai 1 abl e ( ) ; return O;

Nextchar ( )

int t = LΪME_TIMED_OUT;

if C 1char_waiting ( pos_in ) ) DelayC ONE_TENTH );

if ( char_waiting < ραs__iπ ) .his ii an bi line *.-' " getc ( ρos_in );

- 7 3-

newpos/requests.c

ttinclude "types.h" ttinclude "const.h"

char *Keque5t t'-[_.._ ' . .>pf. unsigned type; C char *s:

switch ( type )

case AUTHORIZATION_REOUEST: s = "0100" 5 break; case CAPTURE_REQUEST: s = "0220" ϋ break; case TABLE_REDUEST_ s = "0350"5 breaI de aults s = "0000"; break;

returr. Ξ;

Pop1 ■,_■-. /p.o ( aty e >

,r

if < memcmp ( atype, "0110", 4 ) == 0 ) return AUTHORIZATI0N_REPLY; el e l-f i .nenicmr- I a vpe, " Lo'V , .'| . =- . return AUTHOR1Ztt ri H ..r.L " l''.JCϋ I _

6ι≤t j ' ii. .l.C lϊuj ' a v t i "' >.' _' " ■ ' ' " - ' <

eturn CAPTURE_REPLY; else if ( memcmp ( atype, "0220", 4 ) = * = 0 ) return CAPTURE_REQUEST; else if ( memcmp < atype, "0351", 4 ) == 0 ) return 0UTLET_TABLE_REQϋE3T; else if ( memcmp ( atype, "0352", 4 ) —~= ) ' return FIT_TABLE_REQUEST; else return 0;

— fl^A —

newpos/restore. c

ttinclude "types. h"

A. ttinclude "const. h" ttinclude --istdio. hi' * -

Resxore_al1 ( ) r

Pos_request *r ,

PS FILE *f;

Statistics *The_stats( ) ; Outlet_info *Outlet_information( > Fit_info *Fit_table< ) ,

*ι ; unsigned size;

if < f = fopen < POS_DATA_STORE, "r" ) ) r

log_ρo . "restoring data" > f get •. .-=>_ re . sizeof < SJ :e ι , . > :;

Set_5equer.ce_nuiT.bsr t size ); fget( £-.31 ze, sizeof < size ) , f ;

Set_remote_tι meout ( size ) ; f get . The_stats( ) , sizeof < Statistics ) , f );

-f get < Outl et. in l nr mot. on ( 1 „ __ i :_ . '-! . Hu Lf-l .ii-f o ,, !

. =- Pi t. t<_. e< .-317-f- ■ i i ClC I 1., =-- --_.•, ! ' '•,

while ( f get ( h.p , sizeof _ p ) , f ) *** -= sizeof ( p ) )

if ( (r = Allocate_request ( ) ) - ** - * = NULL_REQUES r — Allocate reserve ( ) ;

**r = p; r->NE T = NULL_REQUEST;

Enqueue_request ( r ) ;

fclose( f ) ; f = fopen POS_DATA_STDRE, " " ); fc1oseC f ) ;

newpos/εave.c

ttinclude "types.h"

-r ttinclude "const.h"

•t ttinclude "istdio.h/

FILE *-f; unsigned size; Pos_request * ,

*t; Statistics *The_stats. ); Outlet_info -*Outlet_infor ation < ); Fιt_ιπfo *Fιt__table< ),

*ι ;

if 'a. f = fopen < P03_DATA_3TQRE, " " ) ) r L

S3 ze = Sequence . number * . ) ; ut ( 2-s.r.e, si eof'' si e , f ) ;

Ξi e = Curren _remote_t i eout > '• ~ f put . I-' IZCJ,, 3 Lzeof '•■. size ) , f )_ ut< The_stats'. > , sizeof ( Statistics . , t . r, fput( Outlet_.ι n-f ormation . ^ , sizeof < 0utiet_ιnfo ) , f )

l = Fιt_table< ..size ); f put ( J , si e , f ) ,",

for ( p = Fi rst_r quest ); p; p = t )

_r

I. t = Next_request ( p ); f put ( p, sizeof ( *p ) , f ); Dequeu.e__request < p ) ;

fclose ( f ) ;

->

else log_pos< "CATASTROPHE - CANT SAVE DATA" );

newpos/sequence. c

ttinclude "types. h"

ttdefine MAX SEQUENCE 999

static char _seqbu.fr sizeof . Asequence . t 1 3;

char #Ne.{t_sequeπce < )

,r tsprintf ( _seqbuf , "7.03u" , _sequencett ); i . sequence > MAX_SEQUENCE )

_sequence = 0; return _seqbuf;

Set_sequence_number ( n - unsigned n;

'

unsigned bequence._r.umber ( )

return _sequence;

— ^ -

πe pos/εtats.c

ttinclude "const. h" ttinclude "types. h"

Lni i lize_st tistic5 ( ) r

zero( §._s, sizeof . _s . ) ; _s.START = calno ( );

R ~ eset_stati sties. )

unsigned queued__a, queued_c ;

queued_a = _s. QUEUED_AUTrlORIZ TIONS; e d _C — ..5,i_:ϋEϋL_._Lr." ! SJ EOJ

Initialize_statistic~.'- .• ;

_s.QUEUED_AUTHORIZATID S = queued_a; _s.QUEUED_CAPTURES * - *** queued_c;

_- ,_

- τ4 -

Co.τιpute_ol dest_c ρ tiire < ) ; return S. s;

Copy_statistic5< b, len ) char *b;

Compute eldes c-. l re ' t memcpy < b, '_-=. ien sι eoτ ( _s ) *"■ ler. _ _,] &oi

Log_remote_uπavai1able( )

'.LINK DOWNStt;

Compute_oldest_capture < >

Pos_request *p; Ti mesta p oldest, now = eal no ( ) ;

oldest - no _ for < p = FIΓ-I J ---quest 1 • ,; u p — ! le * I rι_._|u-. '- . -. • if < p- REDUESr_T'r , E == CAPTURE_REDUEST -:-h p-

CREATIOM TIME = oldes. > oldest = p- CREATION_TIMEs

s.OLDEtπ CAF'TU F - πLde t ~ =~ now " OL i.ltle- ' l -

Log_queued_caρture< )

s.QUEUED CAPTUREStt;

id. aU QF 2axλ

s. QUEUED AUTHOR I Z ATI ONS+t-i

Loα link timeout ( )

s.LINK TIMEOUTStt;

_Qg_aborted_authorisatior- < reason . unsigned reason;

switch( reason )

case HOST TIMEOUT. LOQ host tiff.. case LINK_UNAVAlLAELt_.s _-.>_ ■_-_. t_--ιt-_--_fc___ι_.ι.._..v-_-u. _ α_e . . s D * ea ; case MO_LINK_RESPO SE: Log_l iπk_ti eou ( ) ; break; case LIN _REFUSALs Log__l ir.k_refusal ( ) ; break;

.UTH ABORTSt+s

s.QUEUED AUTHORI l 1ONS--;

Log_link_refusal ( )

s.LIML REFUSALSt ■

_Λ\

s_ r 10S - ' IMEOLITStt;

Log_unsol ici ted_l ιni-_response < )

— i rι.ιι ERROROt-i-

• .1- IOST S VN ERRϋ: " ϊSt ;

."'. * ._ ' -"•.,' r Π"'Γ _. - ≤ι t ~ ι •" ■ r i r_".ρ! - ! ,, aris-Aip )

r

Ti estamp dt;

-~7S -

_s . QUEUED_AϋTi-10R I Z AT I QMS — ;

i f ( answer )

_ε.CARDS_AUTHDRIZED++; else

_s.CARDS_DECLI EDtt--

cli. - e_.__.lnc_.-- . ) — p-.--GREA .[; " .' •■ '• i-iftE if ( _s.SHORTEST_AUTH = * = OL > _s.SHORTEST_AUTH = dtϊ

if ( dt > _s.LONGEST_AUTH ) s.LONGEST AUTH = dts

AUTH SECONDS += dti

5. VERAGE AUTH RESPONSE OTi AUTH SECONDS CO

Loq_caρture_reρI * y ( p ) Pos_request *p

___... CAP URE_COUN " l +-+ ; s.QUEUED CAPTURES— %

dt = ealno ( ) - p->CREATION_TIME? if ( _s. SHORTEST_CAPTURE **** -= OL ) s- SHORTEST CAPTURE **** dtϊ .

-75-4 -

ι < dt - __,. LONeEST_CAPTURE )

_s.LONGEST_CAPTURE = dt;

_ε.TOTAL_CAPTURE_SECONDS += dt; s.AVERAGE CAPT RESPONSE = * s.TOTAL CAPTURE SECONDS /

.LRC ERRORStt;

Lcιq_fi.emory_£ιl locatιon_fai lure ( )

/* means bad loqic buα 3 n svstem */

1 N 1 r.RNftL F ILURES-i-i-

*

-7SZ-

^include "types. h" ttinclude "const. h"

Check_f or _.request_ti meout s •' > -r r-_-:-._reqυesL -s-p ;

Ti estamp- now — ealnow ( ) ;

for ( p = First request C > j * p; p = Next_request ( p ) ) if ( p->EXPIRY_TIME < ****■ now ) switch ( p->REQUEST_TYPE )

-C case TABLE_REQUESTs

Timeout_t b1 _request < p ) ; bre k; case AUTHORIZAT10N_REQUEST_

Ti eout_authorization_request ( p ) bre s case CAPΪUκt.__κE-lUES ' f _ if . p~>ST TE == AWAΪTI B...LI K__RESPONSE )

.-

p—>EXPIRY_TIME = now t Current_remote_ti meout < ) p->ΞTATE = AW ITING_3END; Loq link timeout ( >

Lreα!

Ti meout_table_requeεt ( p ) Pos__request *p;

ϋeal locate _r6_jult..;-|

Tιmeout_authorιzatιon_requeεt ( p ) Pos_request *p; r

unsiqned reason;

if ( E ulat_ πq ( 3 )

Ser.d__reply._to_ client ( p- CLIENT, MA. E_ IT_A_PRE_ΓΆ",

"99999", "00", '3' > Dequeue..!- quest i D ) I ije_.il i ~_ C Z<ι.r'_fι-:'q.ι_.__ >. . ι Lou a_.ii :> -tfrij. au hor3 :at.i or.. " i s et rr.;

5*

switch < p-. STATE .

- -

case AWAITINS_LI |: ._RE3F'GNSEs reason = NO_LINK_RESPONSEϊ brea case AWAITING_HOST_REPLV: reason = HOST_TIMEOUTs break;

Abort_authorization_request < p, reason ) ;

Abort_authorizatioπ__requεst ( r, reason )

Pos.;--equest *r; unsiQned reason;

Dequeue_requeεt ( r 55

Send_reply_to_client r->CLIENT, MAKE_IT_A_PDST_PAY, "OOOOO"

"99", '3' ) Log_aborted_authorisation . reason ); Deallocate request ( r ) ;

newpos/types.h

V

* ttdefine MAX_LINK_MESSAGE_LENGTH 128

typede-f char Message_typeC 4 1; typedef char Lin. _messaqer MAXJL. IN. _MES3AGE._LENGT, . " J ; typedef long Ti nestarnp; typede-f char AsequenceC 3 1 ; typede-f unsigned Tid;

typedef struct C char PAC ET_TYPE;

Message_type TYPE; char LIME \ ' -•- either

Asequence SEQUENCE;

/ * The request data type */

t odef struct pr _ struct _ρr -.'-NE T;; t- queue Lin! struct _ρr -PREV; - queue I a nl x ,' Tid CLIENT; /* who wants to 1- now ■* unsigned REGUEST_TYPE; * binary of Message type */ unsigned TIMEOUT; /* how long to wait */ unsigned TRY_.COUNTER; α. i-zii nrie l U*l( ' I I I I I I L I I ' I i I .." .' I _ I . > r.W-i i _ ] I i. I i * 1.1. _

/* awaiting send */

Timestamp CREATION_TIME; Timestamp EXPIRY_TIME.; Link_tag TAG; Link messaqe LINK MESSAGE; /* what qoes out the wire */

Pos__request;

#de ine NULL_REQUEST (Pos_request *)0

typedef struct -C Link_tag TAG; char TERMINATOR; /* EOT */ char LRC; /* LRC */ Link response;

typedef struct -C

Li πk_tag TAG;

Link_messaqe LI K__MESSAGE? 3- Host_rsply;

ty edef struct -C char DUTLET_NAME_i 31 1; char ADDRESSIC 19 " J ; char ADDRES32C 19 1; char PROVINCE!: 31 3;

!.' * !__.i

char SERVICE_STATION_NUMBERC 6 1; char PROVINCE_NUMBERC 3 3; char OUTLET_NUMBERC 6 3; char DE ICE_NUMBERC 3 2 ; char SECURTTY_CODEC 7 !; J Ou J r-t _ i nfo;

t pedef struct C char CARD_PREF1X C ώ 1 ; int TIMEOUT; int ACCT_FIXED; int ACCT_FIXED_LENGTH; int EXPIRY_DATE_RELATIVE; ' int EXPIRY_DATE_FI ED; char CARD_CΛrEGORY; 3 Fιt_ιnfo;

t 'pede-** struct ' "

. ne αr.od '.rif.UNI •; i * .signed PRICE;

...r,_,igr.c PROD'JC 1"; unsigned VOLUME; unsigned CLIENT; unsigned DAVE; char LANGUAGE CODE;

- 75S-

j- * lr an sac t i on ;

typedef struct -C

Timestamp START;

Timestamp QLDEST_CAPTURE .

Long τιnuτt_fiiLL_AUTH SECOND.

1orrg TOTAL_CAPTURE_SECONDS; unsigned LONGEST_AUTH: unsigned SHORTEST_AUTH; unsigned AVERAGE^AUTH_RESPONSE; unsigned AUTH_COUNT; unsigned AUTH_ BORTS; unsigned CARDS_AUTKORΪΣΞD; unsigned CARDSJDECLINΞDs unsigned LONGEST_CAPTURE; unsigned SHQRTEST_CAPTURE; unsigned AVER GE_CAPT_RESPONSE; unsigned CAPTURE_CQUNT; unsigned LINK_DOrJNS; unsigned LINK TΪMEOUTS_ unsigned LI K_REFUSALS; unsigned LI K_SYNC_ERRORS; unsigned HOST_TIMEOUTS; unsigned HOST_REFUSALS; unsiqned HOST SYNC_ERRORS ~ unsigned LRC ERRORS. unsigned Ϊ ,ERNAL_ Ffi '. ■ . ;E3-

unsigned QUEUED_AUTHORIZ TIONS; unsigned QUEUED_CAPTURES; 3 Statistics;

t func ions */

li estamp ealnow( ;;

char -κ-Request_type(. ),

*Replys_respαnse_cαde< ) , *Replys_auth_code< ) , Replys_language_cαde( ) , My_line< ) , Bcc__of . ) ;

Pos_requesl. t*-Al lαcate_reι_-uest . ) ,,

#Fιrst_request ( ) ,,

*A11ocate_reserve< ) ,

-!-Ne;.t_request ( ) , r.-Matc _ Lin1 _resuor.se( 3 ,

Ηl3toh. -,o_r!- . _ -3Dl* < J ,

*Fι rst_auth_a aitιng_send ( ) .,

*r- " Fιrst_capture_awaιtιng_send < ) ;

Transaction -x-Decode transaction ( );

--~7fe0-

newpos/dead/pos.c

#include "types.h" ttinclude "const.h"

■ nclude stdio.h>

int argc; char *argvC

Initialize, argc, argv )

Initialize, argc, argv ) int argc; char *argv 3;

Initialize_request__ρool ( );

In1 1al ize_queue . .• ;

Oρ n_re.τιote ( arqvC 1 3, ini ti i_trap , NO_E>EVIC. set_ti.τιer_ρort < POS_PORT ) ;

ttdefir.e TAG1 "0100A999" ttdefine TAG2 "0100A111"

Test_matcl-ιinq ( )

Pos_request *r; Lιnk_response 1; Host_reply h;

r -- Al1ocate_requestt < 3 ; strep / ( ' „ " — .."...I. ! ι' .... ! r- STATUS = AWAI f J G_L.N. _RESP0M5E;

Enqueue_request ( r ) ; r - Allocate_requeεt < 3; strcpy( _*r-'TA6, TAG2 ); r-:STATUS = AWAITING_HOST_REPLY;

Enqueue_request . r ) ;

s rep, , hi.T G„ TAG1 ) ; i ( .- *** - * Match_L r.l _re-_.por.se . hi 3 ) tfprintf < stderr, "HIT\n" > else t pnni*. . stderr , ) ;

s rep-.' . 2-1. TAG, 1 A _2 < _ i-i r - Match. ' -. nl _ t e-μon=-o ■ hi . ■ tfprintf ( stderr,, "HIl n" ); else tfprintf < stderr, "NOHITNπ" );

tr-C y . hh ~ ~ l * . I A(ϊ I ' ~ i s ( ■• ~ r i . i I ... _ t i _ i i ' )

else tfprintf < stderr, "NOHITXn" );

strcpy( ..1-ι.TAG, TAG2 ); if . r - Match host reply. _.h ) >

else tfprintf ( stderr NOHITXn" )

test allocator . >

int i ;-

P._.-_• r eq [Ufc_i-T -x-r i-p;-

= 1. p = A. locate_request . >

i÷t *

i s tfprintf stderr, "DR d\n", DealIocate__request ( r ) ) ;

tfprintf ( stderr, "7.d\n", i );

ϋϊ

Witi L _: ' — A.l j....•'. _ ' ."-•C.ϊ .._-• :•- _

tfprintf < stderr, ""/.d\n", i ) ;

test links. )

Hos_request *r 1 ,

*r2,

*-r3; ri = Al locate_request < ); εtrcpy( r1->LI _MESSAGE, "Hello World 1" ); Enqueue_request ( rl ); r2 = Al Iocate_requeεt ( ); strcpy. !-2->LIN _HESSAGE, "Hello World 2" ) ; Enqueue , request ( r2 ) ; r3 - Al lαcate_request . ); strcpy ( r3->LI K_.I ESSAGE, "Hello World 3" ); Enqueue_request ( r3 3 » l'Uriip _φ ιCιι .' 3 ; equeue_request < r3 ; ϋi.qut J Li.t ' _r"-e |ueεt . i 1 - ; Enqueue_request ( ri ) ; TLi.τ.p_queue ( ) ;

newpos/i t/admin_iπt.c

/* admin interface to the pos */

fti ncl ude " '"'""'dave_request . h " fri nc 1 ude " --"types, h " #ά-ncl de "-""const . h "

static unsigned pos_server; extern request dr;

pos_ρrobe( s, info, ram, line, timer, sequence, power ) Statistics *s; unsigned -s-info, *ranι, *line, -fttiner, '•' sequence, *ρower;

lb = sizeof ( dr . strinq_data );

zaro( dr . string_data, sizeof ( dr. string_data ) ) ρos_adιτ.iπ cmd ( 1 , PROBE 3 ;

*inf o

*1 i ne — dr . al ue 1 ;

*timer = * dr.value4;

-^-sequence = * dr.valu.e5;

K-po er •*** - dr.valueώ; memcpy ( __- .. dr.st inq data.. Is --. lb ? Is . lb )

pαs_die( )

pos_admin_cmd ( 1, DIE )

pπ_>_reset_st =.t= ( )

pos_admιr._cmd ( 1, RESET_STf-.TS ) ;

pos_gι ve_me_your_inf o ( i ) Outlet_info -x-i ; r w unsigned li = sizeo-f ( *-i ) , lb **** sizeof ( dr . stπ ng_data );

zero, dr . string_data, sireo-f . dr . εtπng_data ) ); pos_adnun_c d ( 1, YOUR_.IMFD memcpy < l, dr . strmςι__data, 3. lb " ~ li : 3 b >

ρo"_>_r,ιve_ πn ■_!-•_ { -, t ra ~ z~z>rύ i n, i )

r \. unsigned li = sizeof < *ι ) , b -- izc-of . dr.Etrinq dat;

Z l?l " O '. .11 " .. C ' . " ! I " I ' ' '_> .~i _ ,3 l; I j . " ii I OJ l

pos_admin_c d( 1, YDUR_FIT_RECDRD ) ; memcpy( i, dr.string_data, li < lb ? li Ϊ lb ); return dr.value!;

pos delete fit record ( n )

dr . V lut-1 — n; pos_adιTιin_cmd < 1, DELETE_FIT )

ρos_load_iπf o ( i )

Gutlet_infα *i ;

unsigned lb = sizeo ( dr . string_dsta ) ;

memcpy ( dr „ strir.q_.data, i , sizeof ( *i 3 < lb ? sizeo-f _ *i ) ; lb ) ; pos ad in cmd C 1, LOAD INFO ) ;

- --. nt

: i t info -" * ri ;

unsigned lb = sizeof ( dr.strinci data )

memcpy < dr. string_data, i, sizeo < *i ) . lb ? sizeof ( *i ) s lb ) ; pos_admιn_crnd ( 1, L0AD_FIT );

ρo_?_.εet..l ini _.tιmeout . n ) u siqned n;

dr. aluel = π; pos_ad.τ.ιn_cmd < J , SET_LIN. _TIME0UT );

pos_give_queue_entr/ < n, p ) ^ unsigned n;

Pos_rεαuest *p; '_ dr,■ valuel = n; i (pos_server * = * =" 03 p =_ St'!" * «P'i

.J! lUU'.uue - in. .ι._ .'ULUL_I:IS dr. _.1 _ ei.1 - *-. t_q ouo. id. < ,

*. send . ρos_server , hdr , p, sizeof ( dr ) ) returr. p- LJNl ..MESSAGEII 0 1 '= ' \0 ' ;

— -? 3-

os adiifin_c.τιd . dave, opcode ) unsigned dave, opcode; **

i (ρos_server * = * = 0) pos_server = detach ( P0S_P0RT ) ; dr. opcode = opcode;

dr. value.-. = dave;

return __iEND pos server , §-dr ) ;

πewpos/int/cfi1es

adι * nin_iπt„ c po≤_int. c power_iπt. c

newpos/int/make ile

CFLAGS = -S +Wc,tu SOURCES = ©cfiles OBJECTS ** = ©objects

" "" "directorys $ (OBJECTS) type all done

πe poε/i nt /o j -_ c t,

admin_iπt.o Pos_int. o power__ πt.o

_-?- * o-

newpos/int/poε_int. c

/* dave's interface to the pos */

#include " * """"davε_request.h"

extern request dr; static unsigned pos_server;

pos_active( dave > unsigned dave; r

dr_,va1ue1 — 0; pos_c.τ.d( dave, ST TUS_OF_POS, " " , "" ); r turn dr.value1;

char *pos_whats_header_l ( dave ) unsiqπeo c_ vs;

_r

pos_c.τ,d ( dave, 6IVE_r-1E_HEADER_l , " " , "" > return dr. string_data;

•.

ρos_ hats_cards_date ( dave , track2 ) l ι _ii- f l-r c i . ..' i;

-7-M-

dr. valuel = 0; pos_cmd( dave, CARDS_EXPIRY_DATE, track2, "" ) return dr.value!;

poε_decode_card ( dave, trac..2 ) unsigned dave; char *trac.:2; r

dr.value! = 0; pos_cmd( dave, WHAT_IS_THIS_CARD, trac..2, "" > return dr. valuel.;

pos_authoπ_e_card ( dave, amount, trac.2 ) unsigned dave, amount; Cher # lr ae >■ ;

dr" ,. v_ιi ue__' — aπiOLU't",

Ui II r iUe i — U ; ρos_emd ( dave, AUTHOR1ZE_ . Cf-.RD, trac.. return dr. aluel;

o_ ti tur (- rai i _: ar 11 or.. 11111 * 11 fir... H I. i f ir !_ " . D . - . . Li.fii L.i" I un rj .'ii _! .' I

char *trac.-2, *auth; unsigned amount, grade, volume, price;

dr.value2 = amount; dr.value3 * = price; dr_. alue4 = grade; dr.values = volume; pos_Cιτ.d ( dave, CAPTURE_SALE, track2, auth );

pos_server_alive( )

return detach ( PCS FOR "

oρeπ_ρos_server ( dave ) unsiqned dave;

i- t_tur π pus_.f_.md . vs_ , OPEN

ρos_c.τιd < dave, opcode, track!', aut 5 unsigned dave, opcode; char *track2, *auth; r*

zero< dr. tring_data , sizeof ( dr . ε-tring_data ) )

J -f i ύs server ~- ~~ - .. ' . '

pos_server — detach ( POS_PORT ) ; dr. opcode = opcode; dr. client = event_queue_id ( ); dr.valueό = dave;

COPγ_SAFELY < dr.stπ r.g_rJatc , trc-c.2 > ; ϊtrr.cpvf dr .=•. ring .d<_ι tc". -'- -■''. au h , • »

returr. SEND < pos_server , hdr ) ;

newpαs/int/power_iπt.c

/* power monitor's interface to the pos */

-.r-include """ " 'dave_request.h"

extern request d 5

pos___disabIe_trar_smissioπs< )

pos_cmd( 1, DISABLE_TRANSMIS3I0N );

ρos_enab1e_tranεmissions( >

ρosε_cmd. 1, ENABLE TRANSMISSION )

ρ , _- , =-_ . _--<-.v * e_data . >

μι_.-_-r_L-iiid (. C_.l-.V-__ i-'HI . I

static ρo5_cmd ( dave, opcode ) unsigned dave, opcode;

.'lr ._-sp__.i__.d__. — up Dd&i ϊ .. v IueQ — dave;ι

returr. SEND . detach < POS_PORT ) , h.dr >

Deia-/ l ticks ) unsigned tic. s;

set_tι,τ.er . TIMER.,WAKEUP, RELATIVE, t. c. s >

- -

power/makefile

CFLAGS = -S

SOURCES = Sctilεs OBJECTS = ©objects

pump: -i-(OBJECTS) linkobj c * =ρuιτιp x=objects m=pum .map l=/user/steve/davs sort pump,map -f=l,2 ! copy >pumρ.maρ copy pump /dave/pump

qlobals.o: vars.h

nower /Dower . c

ttinclude <stdio.h.'-

*

/* dave's power monitor */ φ

#d e-f i n e TH I RT * .' SECONDS άOO

itde no 3HU70U{-'N__3TARTED 2 ttdefine SHUTDOWi _CUMF * LETE 3

unsigned Curre t..state-'

main( arqc, argv ) char fcarnv C .3 ;

unsigned pi- tr =

Ini tiali-t . αrq , ar q ) ;

. \~a\~ ' a 5 J '

|.u ι ... 'r - ._.• ''- . - i ' ' i ' i 'L. J. ■_._ i ■ n . \ ' i.

S W 1 t C l"ι . i. '_ ι " i " CM ' t- _ < -= - " ' t-_ '' *

case r'OWER_&.ϋO _ Power_good_state ( power ) ; brea. ; case SHUTDOWM_SI ARTED: Shutdown..started..state < power ) ; brea. u ' *1 i' ' 1 1 ) I ' ■»I' ! ' ' ' t ' i J l ι .'f ' »" ι " 111' i I i *** * i * " ■ ~ ' •: ' { t I. ii ' ' i ι i" , t ! '

- 7-7-3-

DelayC THIRTY_SECONDS

i~Oi'\*fc_»-. p- OCi bC_vt_i f . ..-•__!W»_ * t ) un igned power;

i-f i ower )

Current_state * = SHUTDOWN_STARTED; Lαg_power< "POWER OFF DETECTED" ); ρos_disabl _transmissioπ ( 3 ;

Shutdowπ_started_state( power ) unsigned power;

\ r. i ( !power >

Curreπt_state = 3HUTD0WN_C0MPLETE; pαs_save_data . ) ;

Log_power ( "POWER OFF SHUTDOWN COMPLETE" > ;

Current_state = POWER_GOQD; pos_enable_transmissions( ) ; Log_power< "POWER RESTORED" ) ;

£hutdown_eo.πρlete_.Ξtat._' ■. power ) unsigned power; r

if ( power )

pos_enable_transmissions( ); Currer.t_.stat = P0WER_G00D|i Log_power ( "POWER RESTORED" 3

Inιticilιze( argc, ε.rgv ) lnt ar i ; c . r -war vC J ; r

i ( argc != 2 ) r

tfprintf ( stderr, "power •' .device An" ) ; e;: i t ) ;

un on 1 -- ϊ. -d r. ■ • ' " !. ;: ?■ i.fu ., »

Log_power . "START" ); if ( !Open_power_moni or < argvC 1 _J ) ) f _.

Log_power ( "no device" ); ex i t C ) ;

Log_power< "READY" ) ;

-7J4-

power/power.map

.Segment: 1 OOOO to OABA (2747 bytes) •Segment-2 OOOO to 018C (397 bytes) .Segment:3 013D to 023C (176 bytes) .Total size l OCFS (332'>> b « -tes

COi 0053 prologue

COi 005E epilogue

Cυi 00ό7 st. _overflow

COl 00S3 -fucbeg

COl 0084 .0pen_power_monιtor

C01 00CD Power_avaιl bl _.nαw

COl 0104 main

COl 0167 Powc_r_qαod_state

COi 01SA Shutdowπ_started_state

COl 01C2 Shutdown_complete_state

COi 01E6 Initialize

COi 025C Lαg_power

COL 027 1request

COl 02C pos_dιsabie_.trans issions

CO] 02E3 pos_enable_transmιssions

COl 02FB pos_.save_.data

CO 1 034S Address of cυ i ' i :..-.- ■ C f 1 ■ ) 3 "

-?£t-

COl 092C <rewind>

COl 0932 < or ard>

COl 0938 <brea..able>

COi 093E <strcat

CO l 0944 <strc p"•

COL 094A .strepv.

CO1 0950 <str1en ' .'=

COl 0956 <send:.'

CO1 095C '.abort>

COl 0962 <unbreakable>

COl 0968 <vc_send_reply>

COl 096E <vc_create>

COl 0974 <vc_create2>

COi 097A <ve_create3:

COl 0930 <ker_vc_destroy.-

COl 0986 def_server

C 1 098C set_acc_flag t. i I.I'Ύ'I", ' -'..set. - Ico ti on

COi 0998 .escape_tty ' -

C'-.i 099E -:hoid:

COi 09A4 ζunhold.'

CO1 09AA <time_sl ice '-

COl 09B0 <task_infα>

COl 09E-16 fOrc ...ready": l -. < I ' 1'-'Ir.r . ..■ (' !_._ I'l I Gl" J ''. .-

C ' i L l-J'-> .- - -£• [ 11 .'_- f

-7*4-

CO 1 09C3 < set_sl i ce>

COl 09CE <modify_f lags>

COl 09D4 <set_iπt_mask>

COl 09DA <set_int_vec>

COi 09EO < alloc mem>

Lυi '.5- coi 09EC <reply> coi 09F2 <attach> oi 09F8 <detach> coi 09FE <await coi OA04 <signal> coi OAIO *'.write_msg:

CGI 0A16 <read_pόrt:

COi OAIC <csignal> Ol 0A22 <relay> coi 0A28 <creceive>

COl 0A2E -:. iD n > 0A49 < set _e.r t r a_seg > 0A49 < set _eκtra_seg ent;

COl 0A51 <copy> COl OA51 < memcpy > Ol 0A7E <ze o> COl 0A9A DOO OO (" . "" > ≡-p .- DOO c User

-7*5--

--7S&-

0060 < Cod e_f lags >

DO ' 0061 <User_nun.>

DOO 0062 <Broup_num>

DOO 0063 <TeaιTι_num

DOO. 0065 <My_πid>

DOO 0.0.6.7 <.Dads. . -ιi >

DOO 0 ' 0 ' 6v- < My _t t y _n i d >

D ' OO ' 006B < My_cd_π i d >

DOO 006D •• .F.elease_num>

DOO 006E dp_save_area>

DOO 0070 <Fstack>

DOO 0072 < Cal 1 _stac k_p tr >

DOO 0.074 <Seg.τ.ent_table_ptr

DOO 0076 <Check_pαint_sp>

DOO 007S <User_spare>

DOO 007E < (3d b _t i d >

D03 0191 -(Current state>

-78?- power /sample. c

ttinclude <stdio.h>

static FILE *-po εr_ , rr.onι tor ;

-~c-.za.-z i •_. unsi qned .3_ø r . "

Open_ρower_moni tor ( devi ee_name ) r L disallow < ) 5 if ( . power_monιtor = fopen < device_name, "wvu" ) ) ' * = NULL r

power _ mom tor = fopen \ devi ce_na.τ.e " vu" > r, to.pπrt - Addre~<= _of i power.. nom t.or ' ; return 1 ;

eturn s

Hd_.-tιne DCD 0 -O C ttde ine MSR 6

/* 0 bit means power good, * / /* 1 bit means power fail */

F'ow i . .a -ai I a l r>. n H ' ' .'* u-.'!".-. π.-. t. v oϋ-iliO Data nrri. ι .V-l ."ι

i i i !... h I I" ,

- ??S -

bit = ( io_in( io_port + MSR ) h. DCD ) ? 1 : O5 return !bit;

pu.

glαbals.c lts.c messages.c my_timer.c ailure.c tidle.c versions,e p rn .c service_dave.c

-7S3-

pump/const.h

ttdefine GIVE_STATUS 'S /# LTS command codes */ ttdefine READ_DISPLAY_DATA 'D' ttdef] ne AUTHORIZE

•Mde -i r.e SE1.PRICES ttde ine OIVEJDPTIONS '0' ..define ΞET_PRE_PAYMENT Ε' ttdefine BIVE_PRE_PAYMENT_STATUS R' ttdef i ne CLEAR_POWER_UP P' ttdef l ne GIVE_VER5I0N ' ttd ine SET_ 3ALE_C0r 1PLETE ttde ine 31 VE_CAf _TOT AL ttde i 1 π e G I VEJTRED I T_T OTAι_ ttdefine TLIRN_MOTOR_QFF i+def. ne TURN._MOTOR_ON N ttdefine SET ALLOCATION

H-d ri .;. _.T3 COMMAND LENGTH

ttde ine MOO. i OO 1 .'> LTS Status lz-x L-~. ttdefine MOTOR Or! 0002 ttdefine ZER0_FUEL Oil 0004 ttdefir.e REAL_FUEL_BIT o- ; OOOS

-Fl d .- n --■ £ "• n_ ,: _ i " OMF'LL " 11 f ) ' >

Ik-lb-

- ?30-

ttdefine PUMP_TIMEOUT 0x0200 ttdefine TEMPERATURE_F ILURE 0x0400 ttdefine PULSER_F ILURE O 0800 ttdefine LOC L_PRICE_CHANGE OxlOOO ttdefine NOT IN SERVICE O..2000

-I KJJ-.T A-i IK O. v OOo l ■ "• ttdefine LTS_MES3AGE_LENGTH 0x 2 ttdefine LT3_BCC 0;:0003 ttdefine LTS_SEOUENCE_RANGE 0x0004 ttdefine LTS_SEOUENCE_MATCH 0x0005 ttdefine LTS_ID 0x0006

ttdefine LTS_CONTEXT 0x0007 ttdefine LTS UNKNOWN 0x0008

#deFme __TS_AUTH JN'v'ALID NA' : stu. t≡-S/te ι ttdefine LTS_PUMP_ON_INVALID 0x0002 ttdefir.e LTS_NO_PREPAY 0x0003 ttdefine LTS_MO__PRICES 0..0004 ttde ine L S BAD DATA 0..0005

REJECTED o, oo

ttdefine METER_FACTORS OxOOOl ttdefine PRICE_VALID 0x0002 ttdefine MANAGER_MODE O 0004 ttdefi e INSPECTOR_MQDE OxOOOS iαef re hP.: .DLL JR ι.L.0.

ttdefine TIMEOUT -1 ttdefine MAX_MESSAGE 80 ttdefine ACK 0x06 ttdef 3 ne END 0 05

ttdefir.e MAX_RE1 KIES 5 ttdefine HALF_ΞECOND 10 ttdefine F1FTH_SEC0ND 4 ttdefine ONE_SECOND 20

ttdefine NHOSES 3 ttdefine L0ST_PUMP 'L' ttdefine BAD_STATUS 'S

ttd ex 3 r. e UNCHAR ( b . ( < b , - '0 ' 3 ttd et l r. e TOCH AR < b > Kb) + '0 ' )

fΦdef _rιι. TGUCI-!COM_MODE 0

#d&.ι ..e NA " I .'."-. MODE i

-1U-

pump/excepts.h

ttdefi e NO_DEVICE ttde ine MO_TIMER ttdefir.e MQ__STATUS ttdet- in e MO._PR 1 CES ttdef ij-ie USAGE 10

ttdefine NO_DISPLAY_DAT ttdefine NO_PUMP ttdefine NO_PRESET ttdefine NO_AUTHORIZE ttdefine NO_PO ER_RΞSET ttde ine NO_SALE_COMPLETE 10 ttdefine NO_VERSION ttdefine BAD VERSION 12 ttdefine NQ_PRICE_CHANGE 13 ttdefine NO_CASH_TOTAL 14 ttdeti e ttde i e NO_MOTOR_ON ttdefine NQ_MQTOR_OFF 17 ttdefine NO ALLOCATION

pump/ ailure.c

analy__e_and_log_failure( daves_op ) unsigned daves_opii

c1. r » . „ logmII SO Is

if ( ac.._status< > = ***• 0 hh πak_status . ) = * = ) pf = "link"; else if ( ack_status( ) hh check_character ( ) 3 pf = "check"; else if . na. _5ta.tus < ) ) pf = "na. " . el=>e pf = "status"?

ϊspπntt ( logm, ""'_=. -rail Lire- Lop .d op "'.d ns "'_' " >. " ,. as .o -_c 7, _ -; j T i z op ~ .jcie . t ., da» e<« O . na. __=: .V'tus t " -' , a t- _stειtu_= ( ) „ checl __c.._.r ~ i-_f£.f • ' < ,

og_.pLi.τ.ρ . J on.i. 3 :;

pump/ unc.

unsigned lts_status (), lts_display_data () , ltε_powsr_up_reset 3 ,

char *lt5_comrnand . ) ,

*lts_sof tware_version (), *lts_data () ;

pump/global s. c

^include "canst. h" ttinclude "pump.h"

ttde ir.e GBLGEN ri ϊcl ide "vars.h"

pump/l s.c

ttinclude "const.h" ttinclude "pump.h" ttinclude "vars.h"

' clude * "excepts. ' h"

char _version_bu f er [ 15 ];

char *lts_sof tware_version ()

.r." - char *c = lts_comfr.and (GI VE_ VERSION ^ O) unsigned i = MAX_RETRIES, st tus = O;

zero . version buffer, sizeo-f ( version buffer))

tor ( 5 ι: l— .

|_>L.!I>!_. ι._ι_M..ιTi_s.nd (_.)

( 11s_good_rep1y C0)

memcpy ._verεion_buf er, lreply. lr.r_data, return version buffer:

1 j r _ _ -ι , , j I.—i r ti— nr-. »- —,κι \ _

r e._:.;ι t--ir, U_

lts_turn_ otor_on ( ) •C char *c = ltε_command( TURN_MOTOR_ON, 0 ); unsigned i = MAX_RETRIE3,

f or ( ; i ; i — ) if . puιTip_coιτιιTιand ( c ) . if ( status = 1ts_good_replv ( 0 ) ) return status;

Its -Failure. NO MOTOR ON );

ts_turn_mσtoι-_αff ι 3 r

char = 1ts_command < TURN_MOTOR_OFF, 0 ) ; unsigned x "- MAX_RETRIE3„

i-; i ump_command -, s ) if ( status •= 1ts_good_reply < 0 > ) return status;

3 t=- failure . MO MOTOR OFF i;

char *data;

-C unsigned i = MAX_RETRIES, len; char *c = 1ts_com and <SET_PRICES, 0> %

for . ; i; i— ) r

if ( ! pump_command (c) ) continue; if C lts_good_reply CK') ) C c = lts_data ( data, O, S.len); send_coιτι.τιand (c, len); return;

Its failure (NO PRICE CHANGE);

lt3_set_allocatioπ_l i.Tiit ( ) \ r. unsigned i - MAX_RETRIES, len; char *c = lts_commaπd( BET__ALLOCATION ., 0) ;

f- or ; i- i — )

if ( ! urnp_ ommand (c) > continue; if ( lts_good_reply CD') ) r

- __ j t ** .. .! ** -.I

I i III i .

3end_co.τ.mand < c, len) return;

Its failure < NO ALLOCATION )

it- totaJ * _ L. ) un_»_ gned ΠQSE; char *b;

l I , I I ri'

f r ( ; L ; J — )

l -f . ' purr.p_ . command i c ) ) cont l nui. "

memcpy. b, 1reply.lr.r_data, 25 ); return;

Its failure. Nu C

lts^credit_totals( hose, b ) unsigned hose; char *b;

unsigned i = MAX_RETRIEB,

1en; char *c = 1ts_co.TiiT.and ( GIVE_CREDIT_TOTAL, hose )

for ( ; i; i— ) r

if ( : ump_CQιτuτιand ( c ) )

if . its y ι_J-__i- «_?|jl * y ( U

T.e.TicpyC b .., Ireply. lr . r_dat; return;

Its 1 υ NΠ .ED: TO

unsigned lts_status (h) r

char -c = * • l s_ command (GIVE_STATU3„ h);

LH-.-I qned . ~ MAX .RETRIES.

(or . ,i l i i — )

J T . L'ιT.p_ COiTnTiand <c) ) if . status ~ 1 ts_.good_ . repi y (0) ) r

if (status ... P0WER_UP . lt5_power..uρ_re ** et O; retu n sI:atus-,

its ] lure (MO STATUS)

I - -. i .. ... I . r i i r~

i i _ . „ι i .— i r r ..-.I, tl— rr, i ||— . , . i .. ι->i.ιι.ιciι <ϋ '. . -l-i i r _.ι Uw r._ -I. ι . u -s gne i l-i A)...RETRIES, status = 0;

for ( ; _ * ; i — )

I < l '.. " .. '. L IIIUe I III I C > ' r.- l-'f - i ".."n t i i " 1 i

I . -1 I i i t

_-So2-

lts_failure (NO_POWER_RESET) ;

lts_ρriceε( b ) char *b;

char *c - 1ts_command (READ_PRICES, O) ; int i = M X_RETRIE3;

or ( ; i ; i— > if ( pump_command (c) ) r * memcpy Cb, 1 reply. l . r_dat , 24) ; retLirn;

lts_ ilure (NO_PRICES) ;

unsigned I s_displ y_data (buffer) char -s-buffer;

char *c - lts_command CREAD_DT3PLA ' Y " _DAT , selected_hose) unsigned i — MAX_RETRIES, status;

. — .'...

- t>3-

if ( status * = lts_good_repl y <0) ) r

memcpy (buffer, 1reply. lr.r_data t 2

17) ; return status;

.ts fa_ Lure (MO D13PLAY_DATA>

lts_preset (amount) unsigned amount; r

unsigned _ = MAx_ ET IES,

1 en; char -. c — 1 _-._ c.fiii-.i ii...1 >.GΞ 1 _PR__._l-'f-ιYMEM i „ '.'•) asci ι_amoun t C 20 3;

tsprintf (asci i _ ruaour.t „ "".04α",, amount-;

i -i if ( Lt___good__reply ('L') )

■ -■ it-- 1" ι . α^c. "i ifi.ri i.il - " , ' * -_erι> -, .....i 1 ', ._ i J . -r . i i

lts_failure (N0_PRESET) ;

L.ts_p ' reset_statL.s () r

unsigned i = MAX_RETRIES;

char *c = lts_command (SIVE_PRE_PAYMENT_STATUS, 0) ;

for ( ; i; i—) r

if ( !pumρ_coιTιmand (c) ) continue;

if ( lts_good_re Iy ('M') ) return ;

Its failure (NO PRESET) 5

lts_sale_coιTiplete ()

char *c = lts_command (SET_SALE_COMPLETE , 0> ; int i = MAX RETRIES;

D im ι_ -jiiimari -

if ( 1ts_good_reply (0) ) return;

Its failure (MO SALE COMPLETE)

i _.!_>_ clLli. TlUf 12K \ Ci 1 int h; r_ char *c = 1 ts_command (AUTHORIZE, h); int i = MAX_RETRIES;

f or . ; i ; i — ) i ( ρu.-nρ_co. * nn.anα (c) ) i f ( 11 =»_qood__reρl y (0> > retur r.; Its failure (NO AUTHORIZE);

1 >r i == i i fit--'. I r. at _ t_ _Λ LI __■ ., upcude i,

** char chec.-_char;

unsigned 1tε_good_reply ( c ) ~ |-.,ι!- c.

._.._'._ I Li

- So-G-

if ( lreply.r_type == ACK )

%_. ack_status = 1reply. lr.r_statuε; if ( c == 0 ) return ack_status; else return lreply. lr.r_data C 0 -= check_char;

else nak_status = lreply. lr.r_data C 0 3; return O:

c-lear_lts_status( opcode )

Ltnsi gned opcode; C ack_status — O; πak_status = O; opcode — opcode;

check character ( )

return check char;

.k status

return ack status;

nak statu ( )

returr■ na statue,

lts_oρcαde( )

return opcode;

int code; r \. longjmp ( *selected_trap , code ); code •• !- ■* = 1;

pump/make ile

CFLAGS = -S SOURCES = ©cfiles OBJECTS = ** ©objects

pump-s- * 3T(OBJECTS) liπkobj c=pumρ .t=objects m=pumρ.map l=/user/steve/dave sort pump. ap f=l,2 ! copy >pump.map copy pump /dave/pump

globals.o: vars.h

pump/messages, c

•ttinclude "const. h" #ι ncl ude "pump.h"

static char lts_buf C LTS_C0MI'1AND. LE 5TH * 5 J =• C EMQ

lts_data (data, h, len) char *dat -__.>a; int h, *len;

,r

reqister char -s*-c * = 1 ts_buf t l;

*c++ = ' 1 ' ; -'* sequence number #,'

*c++ — TCCHr-F.. ρuι * ιιρ_. ri-ifiiCiei" ) ϊ .-i"- id *. i id — pump >- ' #c++ = TOCHAR(h) ; /* id field - hose */ strcpy l , data) ; c .-- strlen (data) ; c- 1 --. _ ** j * -_ι_ . ei"ιϋ ci-. mo*_>__■ag.

, ,__ -H- __: _;.., j ._ _ιj .?. I; ._■■ fi . ( I s ou i

* L er i = DLlT

returr. Its buf

i iCii

int h ?

register char *c = lts_buf + 1;

*c++ = ' 1 ' ; /* sequence number */

s-ct-i- = TOCHAR(pump_number) ; /* id field — pump */ TOCHARfh} Ϊ •' & id -field - ϋie -s-

¥rtZ_rt-a- = " Dμι__->d__ , 5

.C++ = DEL; / & end of message */

*c++ = calcul at e_bcc (lts_buf, TS_COMMAND_LENGTH - 1);

return Its bLif;

r ll Lll _lt_:_faC-. (ill, 1 ) char *!ϊi;

reqister int bcc * = * O; reqister char *p = m;

... ? 1 '

ft-DT—f-

return bcc:

send command ( , len)

-£4A-

f flush (input) ; fput ( , len, output);

pump . .m (data ;

fdata = 0; / * assume failure

for ( l = 0; i -! 20 _ l t )

•'■ Loo I for start of n.e^ϊ. acje *•' _;.• ■■ ι cl * . - : r.E?"tcn * -! . ) >

-et i n αet messaqe ι dat. ι _=ι

'■-I .I- ! ,, > Ml...' file...-'-. r. L.|r... V

get_messaςι& , data)

c I 'J L '.'

-S -

int bcc,

num chars 1;

bcc = c; /* initialize bcc */

*d ta++ = c; /* save start character *..

-or -O

/* nLimber of timeouts allowed */ if ( (c = neκtchar ()) != TIMEOUT ) r

if ( num_chars = * = M X_MESS GE - 2)

/* don't overflow */

*data = .U return O: '* message is too biq

;l e

. um chars÷+π ■-'* ιΛp. <_.>___■ ι_.t_u-

else / * timeout and count it */ itt;

tn

. -.

return U; el e

•f *d ta = .υ

* retLtrn bcc == ne,;tchar () /* bad bcc or a ti eoLit */

. ....'.iiirl I i char -K-C;

send_co,τ,.τ.and ( c , LTS. C0i"IMAMD_.LEM5TH ) ; ero( ..lreρi , sizeof ( lreply ) ) ; cl ear_l ts_statι.ts . c C 4 3 ) ; /* save the opcode * /

|- etu n pumρ_ιn ( °»_ rep] / >

#α . jr.e OMb I EMI H ECOi ID

πe ' itchar < )

- I ( Cl". =.f l-" " \ I 3 r. . . J ! _• ' " ' I t -"- net... . J r i p. u c > '.. u v V -j el se r

dr-1 -iv (ONC " lTENTH_SECOND) ;

,ι . . , .!.' I '

t = getc (input) S. 0s-.7f;

return t;

- 8 5-

pump /my_ti mer. c

ttinclude '. timer. ' :-

static unsigned ta ιτ.er_runnιng , in y

se t __ t L mer _ρ or t ( or t )

my_port = port?

r s t C 1 fiitir

cancel .r.v i mer < i

a. . . '. i iT.ti . r " L'l II i J ι " ιQ )

_..•--. 13,1.1-!- r r MEzr_r? .ri*. " : , ΓLL,VI Λ ~ , ", >, .-.. no.-ι- ) r, iιr.c-r running -= 0;

εet_ιτ.y_tι mer . tιc. s> un -_. qned ti . 1

set_timer (TIMER_SIBNAL, RELATIVE, ticks, 0, my_port) ; timer_running = 1;

delay (ticks) unsigned ticks * ;

cancel_.τι"y'_timer () ; set_timer (TIMER_WAKEUP, RELATIVE, ticks);

--8Λ- -

pump/objects

pump. α service d c.. v t- . U

-SAS-

pump /pump. c

ttinclude "const. h" tt ir. elude "p Limp . h "

# rfC 1 ud " VΞIΪ ~ s . h " ttϊ÷n c 1 -u-d-≥ ' ' un c . h " ttϊt ' clude "excepts.h"

static unsigned timer_portι

.τιδin( argc, argv ) int argc; char *argvE.3; r

X- uπsigned task, code; request p;

initial error (code)

?ls * initialize (argc, argv);

for (

oort

else service_dave (task, &p> set xxiv timer < ONE SECOND );

j r. t p c . char ÷-αar π.sE 33

sel oc ted_.tr ap **** hi ni tial _traρ;

(pc '= 3 hh. pc. ! = 4) long-imp ( ni ti a.l . .trao . USAGE);

f (p..

I ._..... '. r • -- '.1 ι<l— I- -. I . +U

1 og _pu.τιp ( " start " ) •■ set_t iιτιer_ oort .t nιeι-_ poft =• atoi t parms C 1 !) >5 di <=•._.. 1 "H- ) 5

. — ... j. __. _ „ . „ _ „ „ r -ι i iii— ii . - J--I i i r i ,

1. ipLi ' — ... • ι_.μ. -.. i ■ c" r ...- I. — .. . 1 . , i ... ..1 ■ _<_ •-_ >

GLiT-p. I — ι,i i fi ei '..•..' 'iii I _.' 1 ,

U ioch_θLttpαt = .r.v_oρen (parms L 'wvu", ιr._ tia. _traμι , NO DEVICE) ;

*/

— 8-3,0-

longjmp (initial_tra , NO_TIMER) j

flush_input (input); initiali_ * .e_pump ( ) 3

set_.τιy_timer (1) 5 iog_pumρ ("ready") 5

reset_iTiy_timer ( ) ; selected_trap = ?.idle_trapj if ( set mp ( selected_trap ) ) tel 1 _dave_abθLit_i t ( ) ; else

ini ti al ize_pLimρ ()

longjmp (selected_trap, BAD_ VERSION) ;

status = lts_status (0); pLimp_number = * UNCHAR ( 1 rep 1 y _ r_pump ) ;

J. S ΞOt al ... C ' i-t. O 1 '. - ■ " ,• ' , t . i li

- 82Λ -

initial_error (code) unsigned code; r

£ J. *-Cl I { ' -Oϋ ' ϊ r L case ND_DEVICE_ m = "no ser3 ai channel"; brea. r, case NO_TIMER_ = "no timer" s brea ; case M0_PRICES: m ** = "no prices"; break; case D_STATUS; = "no status"; break; case BAD_VERSION: m = "bad version"; breal-; case NO_ALLOCATION: m = "r.o a L local., on" s brea.-;

.__.-„e USAGE. usage ();

trprir.tt .std rr .,

"pump tιm r_port pump device bul 1och_devιce + \n") ; ej. t (1) :

pump /pump.

#ϊnclude " /user /steve/dave/dave_r equest. "

#d efine PUMP TASK ' / d av>__ / .j LiliiD '

ttde-fir.e D. .READ Y_FOR_F I LL #define D_ .HOΞE_SELECTED #define D. .FILLING_DATA #define D. _PRESET_THE_PUMP #define D. _3TATUS_REQ.UEST #eie * fine D. .PRICES Φtd e ine D. .OPEN # efine D. .NATIVE 10 -..-define D_ .TOUCHCOM 11 #defiπe D. .AUTHORIZE 12 #define D. .SET_3ALE_C0MPLETE *. define D. .GI E_ΪD 14 ttdefir.e B_ .3E_QUIET 15 #de iπe E>_ .REPORT_OUT_0? . #de ine D_ HOSE_FILLED #define D_ .IS_HOQK_DOWN 18 #de ine D_ CHANGE_PRICES 19 #define D_ HALT_PUMP 20 ttde-fine D_ RESTART_PLIMP Sde-fine D_ HOSE TDTr.- ; L. -it-de ine 1.'

typedef struct t char r_type; char r__seqj c r r_ urnp ; c r -. a r r _ I". ose; union -l unsigned r , __statusii char r_data C MAX_MESSABE 2 3- lr; lts_reply;

- *tu+- pump/pum .map

.Segment: 1 OOOO to 2394 (9109 bytes) .Segments2 OOOO to 034B (844 bytes) .Segment.3 034C to 06B5 (374 bytes) .Total size is 2A4B (10327) bytes

COl 0053 prαlogLie

C 1 0 5E epi1ogue

CO1 0067 stk_overf1ow

COi 007D <e * - * it>

C01 0033 * cbeg

COl 0084 <main>

COl 00F9 --.initialize>

C01 020D <initialise_purnp> COl 024E <initial_error> CO1 02B1 <usaαe>

.ce ____•

CO: •: .._servι ce.>

COl 03FC < _h o o k _ d o w n _ n o w > COl .0447 <_ρr i ce_request > COl 046D <_read_hose_total i COl 04C2 < _ch an g e_ρ r i c es > COi 05C8 < _i d _r eq uest > COi O 13 < hose f i l l ed ι_oι . n u u a

'_be_quiet.-

_tell_me_yαur_troubles> .dave_waπts_tα_..nαw dave_has_been_told.- __read _to_. i31 *

C i 0753 _se__saL .complete COl 0772 _st at us_r eq uest COl 07C5 _hoεe_sel cted Ol 086D _authoπ e_pump COl 0SB6 preset_amouπt_puιTιped coi 0928 al iocatιor._l i i t_reached COi 7>_ wa_ c or J o rt -- A 7c __> .any e_o . _nuse coi υAAS wai t_f or_f l 11 I ng_stoρ coi 0B73 wait for hoot- down

COi OBDΓ- or .op er t or _.c.b or h Cυi :>C o ■ UI ι_v'a . t'i r s_ or.

•JL. I L 5... ';. ir r ._".."• t * or _c!"ι cυi 0D1E 1 t __• _ t Uι~ . _ ITIO t or _ of .-

CO1 0DB1 1 ts_change_ρrlces COl ODFC 1ts._sei._al 1ocatιon_l: mit coi 0E7G Its cash totals ot \-\l '

C"l "1 " 11.

Cu L 11|- Li J-' -»"-■ . i

-S££-

<lts_prices

< 11 s_di sp 1 y_dat a>

< 1 ts_p reset >

<lts_preset_status>

* : -.1 ts_£-al e_conτρ ._ eι_

< 1 ts_author ize>

< 11 s_g ood _r ep 1 y > <clear_lts_status> <check_character > < c k_st atus > < 1 s_oρcode > < 1 ts_f ai 1 ur e>

(anal y∑:e_and_l αg _f ai 1 Lire. < touchcom_i d 1 _t i mer > < tel 1 _dave_abαut_i t > < val i d_ve si on >

COi ■'.. reset _ιτ.y __t i mer ωot 14CA ' ■. c a π c e 1 _ m y * _ t i e r coi 14FC set_.τ.y_timer> oi 1523 <delay> oi 15 E <It cσmmaπd>

UO i 15F-D i_-u... iώ._M -..s.-_.!-•CJ ι_.j•ϊi.ii<=.π

- &&S-

trrpv

COl 1E9C ---.-=. ι_r I t_ι i .

Cυi 1EA2

COl 1EA8 <abort>

COl 1EAE <unbreakab1e!

COl 1EB4 <setjmp> cυ1 11'a -

COl 1FC8 '.memchr:-

COl 1FF5 -.memccpy

COl 2030 .atol. ';

CO1 20CC 1epl1 ogue

COl 20DΞ l.T.ul

COl 212D lrnod

COl 2133 l.divr

COl 21F5 vc_send_reply

COl 21FB -' vc_create

COl 2201 vc_create2

CO! 2213 d_-f_server

C01 2219 set_acc_flags

C03 22.1- set_e,.ceptιαn

-&Bθ-

COi 2261 <set int mask> cόi coi 226D <alloc mem> Ol "..receive

CO1

COl- 227

COl 2285 <detach>

COl 228B < await >

COi 2291 < sign l . *•

COl 2297 <read_msg> Ol- 229D <write_msg> COi- <csi nal > coi 22AF < relay >

COl 22BB '.memcpy.-- COl <coρy>

301 -304 : . me rr.se ϊ_

Dυυ o io

I ' ι ι

-S2A-

DOO 0067 CDads_nid> DOO 0069 CMy_tty_πid> DOO 006B CMy_cd_nid> DOO 006D _ Rel ease_num .* DOO 006E i. W dp _ssvs.. ar e a . ' - DOO 0O7υ .hstsc k ■■- DOO 0072 . C a 11 _st ac k __ρ t r > DOO 0074 _ Seg en t _t ab 1 e_p t r DOO 0076 '. Ch e c k _ρ o i π t _sρ > DOO 0078 . User _sρ a > DOO 007E :Qdb_tid> D03 03E6 _ht> D03 05IB- . _ver sion __b u.f f er > DOS 052A . a c k s t a t Lt s -- D03 052C πak_statLϊs > D03 052E 1 oρ code > DOS 053O ' . c h e c k c h ar DO " .*- '.-5όv D03 0562 ϋ y._cl i πt> D03 0564 . i π t .- : D03 0566 .bul l ocrι_oι_.tput ' :. D03 056S iDUtput> DOS 056A .selected__hose> DOS 056C .purnp_nuiT.b r> .J.rsc1v .

D03 05DA <request_trap>

DOS 05F2 <id1e_trap>

D03 060A <selected_trap

DOS 060E <dr>

-S3< -

pump/εervice_dave.c

#include "const.h" #incl -de "pump.h" #include "vars.h"

-tf 1. c ι_ x U ι_j _. TUIIL. n

tfl I H- i.J1.Hr-- tefj. "_.t_μ' _.._■« 1 I

static char • eveπt_ιTfsg C MAX_STRINf_._DATA D; static unsigned preset_amount ;

serv * ice_dave dave, p ) unsigned dave; request *pj-

int cede;

REPLY, dave, p

π ____•! ...y ti.nt__r ι . )

-U -.r !_.;. if ( code = se jmp £ equest _traρ ) '

ρumρ_eveπt C ιτ.y-_cl ient , "PUMP FAILURE", code ) anal yze_aπd_l og__f ai 1 Lire ( ρ-*>αpcαde ) ;

θ 3 - * - ** »

service£ p ) request *p;

switch ( p— Opcode

L-EtSt L'._|-.L_ι-.i' i _ r ui,* .1 in.-, _t t-ciu •____ _.!_'. u l i ' ., breaI- s case D_H0SE..SELECTEDs _hose_.se1ected -. . : break; case DJ-1LL_NG_.DATA. _fi11 ιng_data ( ); brea. ; case D_.PRESE f..THE. PUMP: _p eset the pumn < p l Lie- J ?, ]ιrtKϊ.ιι i case ϋ. f-.u-.TU5 REQUESi . __st<?tLi. * _ "fiquei!' -, hr al _ case D__PR1CES_ _pπce_reque__t ( ι ;

I i r " i f I _ C _..__._ I-' _ '-'I * Ll ... ... .l. ' l L ffl l l — )-. " -- 1 1 a. I I L _ , , . i I , . case ϋ IvIfiTiV s •• -(=,_.. ca iύ £i_TDUC; I ϋMs mi -.--it r, case D_ AUTHOF."lΣEs . authorize. , pump . p- ni iiwl ' ; brea. s case D_3ET._3.--.LE_ OMPLETE; _set_sa_ e-_cσn.p] ete . . ;

-— —

case D_BE_UUIET_ _be_quιet( ) ; brea!'; case D_REPORT_OUT_OF_SERVICE:

_tell_fiie_your_troubles £ ) ; break; case D_H0SE_F1LLED_ _hose_. i1led £ ) ; brea!:; case D_IS_HQ0.._DGWN_ _ ait_fot-_hoo. _do n £ );

breal ; case D_HQ3E_TDTALS: __read_hose_tαtal £ t ; break; case D_PUMP__1S_HQ0. _D0WN_N0W: _hoo. _down_r.owC ) real ; defaLtlt: pu.τ.p_event £mv_clieπt , in nil K .r-.ι I.i ι~ it -. „ ι_ i

__IIMΓ I .L ' ■ . - 1 - ; fa real

iuul

:a uΞ .__ =ta ._ fcfVci I l_ lll__ιU

-.status h HOOF ) == 0 ~~ ' "HOD. DOWN" s "HOOF UP" . ρumρ_event x .τ.y * _clιent , event_msg, 0 ) *

_ρ ι c f.. _..i|u&. ' s £ )

lts_prιces£ event_msg > ρump_event £ my_clιent, event_msg, 0 > 5

hose_tot_.l ht C NHOSES 3;

read hose total C 3

u." _ . g ed i ",

zero ( . ht, sizeof C ht ) ; tor ( i = Jj i == NHOSES; 1++-, h++ 3

I l '.. i El*- I i LU .u i ■ ' L , I i " L. -.. ' I

* ._. ': iϋl..I' : ( l . h- ':rcd-!- -total . :;

stcitLc unsigned _ι_am_ thi s_pump

. h ii .-.ir- ni I cc-?- ', p >

•c c unsigned i ,

lts_change_priceε£ p->string_data ); lts_pri eε. svent . msg ) ;

- - ιϊι ',;c: • * p v -f.. sg ? — —

_read_hose_tot al £ ) ;

-for ( t = 1, i = 0; i < NHOSES.; i-n- ) r

load_pLimp_total £ p— >valuel, _i_a.τ._this_ρumρ , htC i l.cash_total , t++ ) ?, load_pLiιTιp_tc-tal £ p— >valuel, _i__am_ thi s pump -

1 o ad_ρ urn _ total £ p— >valuel, 0, " " , 0 .5 Dump event', my client, "PRICES CHANGED", 0 >

vent :1 i nt

_id_reqLiest £ )

Ul t^: J Ol Ite' ^ tλTLlΛi:

-SB'S-

statu=. - 11__._-_tatus £ 0 ) s COPY_SAFELY£ event_msg , "PUMPID" )« even _msg C 6 2 = l eply.r_pump; _i_am_this_pu.τ.p = UNCHAR(lreply.r_pump) R pump_event £ my_client, event_msg , 0 );

hose .1 led ( )

event_msg C 0 1 - _hose_used_to._ i 11 ; puii.p_event £my_clιent, event_msg, 0)5

1 tε_dι spl ay_data ( event_ιτι"_»g ) ϋ _.hose_used_tα._*f 111 = lrepl v _ r_hose; ( v. client, event. msg , 0 ) .

s I at ir 3 r- 1 d L ►--• r _? p or 11 i . q i 1

ιdle_reportι r.g_τl ag = 0;

idle_reporting_*f lag = 1;

dave wants to know £ )

idle_reporting_* lag * = Or-

/ * pLi.ap i __- ready -for -fill i-f current statLts shows no */ - " *' abnormal conditions & /

r

unsigned statu.s, iil_'_. _-'.:. — ) j char #ver ΞX or ■ — 1 ts_ . so tware_versϊ. on £ .. 5

ViTiSU L _jU J j

i-f £ I al i d_ver sio £ version )) r u rnp _e vent £ my_client, "BAD VERSION", 0 ); sr.rin v '■ viT.sq .. "bad version .l2_ IΞϊs" , version

return;

status = lts_status£ 0 ); pLtιτ.p_eveπt ( my_client, (status h. not ok > " "U/S(PUMP) " _ "READY", 0 ) ;

_preset__tt-ie_ . pi.tn.pf an_ mount ) unsigned an_amαunt; r

lts_preset£ an_amoLtnt );

1 ts._preset_status £ 3- pump_event £ m y .client, "r'RESCT" , 0 > 4

set sale complete £3

Iti >ale ._ oπ.p i ir_. * t e

s atus request

unsiqri&d statue i;

event_ιnsg C 1 2 — '0' ~ memcpy( event_msg + 2, ^.status, sizeo-f (status) ); event_msg C 5 2 - '\0'$ pump_event £ my_clieπt, event_ . rr.5g, 0 );

ϊ_cl'JH-E.-' lC'U - -i '''fa or ■/ou iHIeoLIc

ttdefine MftX_SELECT_TIMEOUTF. 120

/* total time then is 60 seconds *-/ #de-fιπe WARNING_TIMEOUTS 60

__ oεe_selected £ r •.- "

ι.' .i _ne __d__ j ti . _τ..ecu ,j.__-- = • >...--., ■_*. _ .o•— rt—_.i rE-i—_- ~ι .-_ i,r_ -r. i.-i .rE—iu—iiϋ 1-7 I- r _ status;

for £ s ti eouts? timeouts— >

status .- HOG. ;

sel ec tεd_hose = UNCHAR . Lrepl f „ r __hos > ; CDPι'_SAFELY £event_msg, "HOSE"' ; event_msg C 4 1 = lreply.r_hc.se; puiT.D t".ent iifiv CJ i eπt _ ev'en f>> i

-St*..3-

del y£ HALF_SECOND ); if £ timeouts =•= WARN I NG_T I MEOUTS ) pump_event ( my_client, "WARMING", 0 )?

p urnp _ eve my _ c 1 l en t , "Til IEOLJT " , O > ; r eL.ir 11 ' " 'j

static long _.prevι DU5_«αl ume_ρ umped;

_authorιπe_pump £ amoLtnt ) Ltnsigned amount; r L

* lts_ρreset£ amount . ; 1 ts_ρrese':. . statii-.- £ . a preset_air.ount - amount; 1 ts_au thoπze £ selected_hose ); Dump_event£ - . client, "AUTHORIZED", O ) • . pre-ioLis -oi urne. p - ped — OL'- d o L r ar. = =ιc t _.01. ' ' °

preset_amour. t_pLι.τ.ρed ( di __.pl av_data ^ char -x-dιsplay_data *

pr.α 1 '.nt. nt impf

atol £ ) ; unsigned amouπt_pumped , f atou £> ;

volLime_pumρed = -f tol £ display_data + 4, σ ) s d-n — -ol ume_ρ umped — _prevι us_v"olLtιτ.e_ pumped; c.t" * e i si Ξ • ol uiπe DL'tr-De — -rcl ' "τ.3 c- > ~ .D-~ΪI ! r

i-t- £ preset_amount == 0 . return 0; aιT'θLiπt_ρumped = fatou £ disρlay_data + 10, ό . ; return aιTιount_pLimped .• * = preset_amount ;

c ar , =ρ 1 a ; dat

* eturn memciTip £ displa _data + IO, "00 -'500

■ - ~ - • >ιr_- _.._.ι.ι.ι_ι t-. i_- t-tϋcf ciut __.'-" i -.e ϊ Xr.r-. •_• . t LUILKS __r * ~ ; --.

• * > the user" pio-.H tp a ci-r- erer.•_. hose than * ' * the one that triggered the authorize -*

/* 2 -rLiel starts to -flow •.-.'

/* ι the user never pumps, and LTS times him out -fc-/

T i r . . ... . . E'Er- l ■ lu.. Hi . :

/* 5. tl"..,. user fills to the preset amount */

/* ά>) the user starts to -fill and puts the hook */ /* back. */

do transaction £ )

p urnp _e vent £ my ..client, "FUEL FLOW" , 0 > ; wai t_-f or_ * f i 11 ir.g_stoρ £ ) ;

Its turn motor o -f £ )

'* L-.u comt.__. are: *. * * -,- ,'

/* 1) Liser picks up a di-f-ferent hose #.'

/* ■ * ==.- tell dave * ■' rt- 2) -fuel starts to -flow -■'

' * --- —. Lt.1 J. LJ . "'f_ r - 1 t h t- war n i n g t r i q q er r ires - . -- =_..__ . tell d a v e • • /

/* 4) the motor turns o-f-f- * .'

/* =-. tell dave #/

#de-fine TW0_SECDNDS 40

-Ird.-j'. i i-i..-- i.'-.I. : !.'._ ,- - -,r, lιr ,-■ , . ■- - -. ■_ ... . :- i f.-: 1

— _

ui .ds +

wait_f r_f uel_f low £ )

L - unsigned timeouts = O, abend = (PULSER_FAILURE ϊ TEMPERATURE_FA1LURE)

for £ ; timeouts _--TAF.T_TIMEOUTS; tιmeouts++ . r w chec _f or_oρerator_abort £ ) ; statLts -= lts_status£ selected_hose ) ; if . status F£EAL_FUEL_EMT ϊ / * fLiel is flowing * / return 1 i else if i .status •.- HOG' 1 -- "■ ~~~ — O ■ timeout = chaπge_of_hose £ 1 ? υ : START_TiMEOUTS: else f £status h abend/ .'* pump is beat -»-

_tu

else if . .status h PUMP TIMEOUT) 11 * Its ga e up on the guy */ rli-I - ?, l-! l1 lJh ' ) =-

pump_event£ my_.cl ient , "TIMEOUT", 0 > return 0; •>.

else if £ timeouts = *** = WARNING_TIME hh. !warned )

-_

delay ( TWO SECONDS );

return 0;

/ >- cListo er had authorized, but put th - hoo. bar.. ,. t* . / *- LTS has terminated the.- , transacti n. assume tt.e-.. x / •' >** istoififc'r wants o ch r. g_- g d_*, a d re- author ι;c -.

chang.

i * ιO' ~r f 1 ~~! t . -t £ < ri" 1".

'. _ ciinOϋl . t ) ? -Λ preset >-or r.ew trr.πsac 1 on 1 ts_preset_status £ ) ;

1 ts_authorize £ sel ected . hose ) ; / * re-authorize */ return 1;

.

ret irn

/*÷ 4) a system reset occurrs */

/* 5) the user fills to the preset amount */

/* 6) the Liser starts to fill and puts the hook */

/* back. *

ttdefine FILL_TIMEQUTS 400

wait_for_fil1ing_stoρ £ )

, •e- unsigned timeouts = FILL_TIMEOUTS, abend **** £POWER UP 1 PULSER FAILURE 1 PUMP TIMEOUT J TEMPERATURE FAILURE) -

+or timeouts; timeouts—)

ooeraror aD

_t. it . status ... aδena .

p rnp_eveπt£ >τ.y_c1ient , "ABNOR L" , 0 ) 5 analy_-.e_and_3.og_fail ire £ D__AUTHORIZE ); r tLirn;

£event...rnsg + 2) ) r ι pu_τ.p_event ' < my_client, "NORMAL", 0 ) 5 return;

3 -f * iiocabi or._11mit_, reached t feven I^Q * ) >

purnp__event < π.y_cl ient , "NORMAL" , 0 )5 return;

delay £ TWO_SECONDS );

puπ.p_event £ my.client, "LONG TIMEOUT", 1 );

ttdef i ne Hϋϋl _ DOWN_T 1 I'lE-DU TS όOf- ι-

_ aι t_f or_hool _dowπ £ ) r

unsiπnerl Li -neouL_-: = HDUl . O M. TJMEOUTS , statu= * •;

-. " or • 3 imeout _. s, iiii ' uts — "*

status = lts_status£ 0 ); if £ £ status h 1-1001.) * == 0 )

3U.1ι| . i" - f I . ' i i I n" .. * . I l ' I. II

- S50-

delay£ HALF_SECOND >

pump_event£ my_client , "TIMEOUT". 0 );

check_for_oρera.tor__abort £ . )

unsigned the_client.ι request r;

if the client = CRECEIVECO, h.r ) >

switch < r_ opcode )

case υ_HAI_T_PUMP_ 1ts_turn_motor_off £ ) ; break; case D_RESTART_PUMP: 1ts_tL.rn_motor._on £ ) ; break;

pump/tidle.c

ttinclude "const. h"

#ι ncl ude "pump.h" ftincl ude "var=_ . "

•H-iπciude "turi .h"

static int versiαn_samρler 3

tθLichcoiτι_idle_ti er £) . unsigned status, good_ve ion = 1, not_o. = £NOT_J _SERV3 E^ s

J. f £ versa or ι_sa.rιplι£.|- ** == C> _ versi on__sampl er = 300; good_.versι on — val id..version ( Its sc ftwar * .. " --e si or.

-ϋrsi a ~ -'X>__ =. amp 1 eι — ;

status = lts_status£ 0 . . if ( dave_wants_to_kno < ) ) if ( ' qood_v-ersιon ! ! (status h πot_o. t ) .

|... '...I . even I \ .Ϊ. - ..1 ιen. , \ι ' ι • ! I

analyze_and_log_failure£ 0 >

if ( status h. POWER JP )

1ts_ρo er_uρ_reset £ )

if £ dave_ ants_tD_kπow £) ) r *. p urnp _eveπ t £ my_c 1 i en t , " U / S £ PUMP > " , O > ; dave_has_been_told £ ) ; analyze and loq failure £ );

pump/versions.c

stati c char *vtab C 2 "700200870626" , "9 < ?9 « ?97370504 " ,

valid_versιon £v) char *v; τ. int i 5

return 1 - .' * HAC. <-/

for ( i - 0; x si dol ( vtab> •' __-_ -.er.-- .ch.-.- • ■ * ; i÷-÷ ) if £strcmp £v, vtab C l II) -=•= 0 return 1;

pump /i nt/cf i 1 es

pump_iπt. c

-SS5 " - pu p/vars. h

Si ncl ude :stdiα.h> * ttinclude setjmp.h

__ i _ι _ r r i j - r i i 1t _ r Lit' I bl I—.. ' -- M

#defin VARI BLE

#else ttdefine VARIABLE e.ctern ttendif

VARIABLE unsigned debug, my_.c] i nt;

VARIABLE FILE rinpu ,

*bLll 1 OCh_OLltput ,

*output ;

VARIABLE unsigned sel ected_hose ,

VA I DL-E l ts_r ep. 1 reply;

VARIABLE jmp_buf miti al_traρ , request_trap , l dle_trap ,

SCH ΠΠT.T! R

/user c /α t uchcout

/user cmds/selector /user_cmds/goservers /user c ds/qodave 1

/user_cmds/selector

/user_cmds/select A 0 ffff 2 /Liser_cmds/select AS 0 S000 2 /user_cmds/select D ffff 2 .-u_.t-_.r- _c..._is.-≤el.- * _'Cfc DS 0 SOQO 2.

/user cmds/ cioser ver

logger

/dave/1oqqer

stlv - o-i 1ow bai ' d-UOO bits— " ' i ' term. sttv -etab -ers -edel -echo -edit -maocr £termi

" start 2200

/d ve/22ό0 Ste mi l B2 h

da ^ e . Do e -i"ter.7.6

"l_.. i l.H'l LJclt lLI- X*.'. )1 .' _. - L. _• —

.5 . ' n "im-.l-.L f ■ LL'i ' ll ' l.

Jl-. • r-l .... j '. I .,.'..' -' . 1

grapni c;

/dav / graph /dave-' art tivf. = . rπap 37o <'•

-8s-

/Ltser_cιτιds/1 oadengl i εh /■-user _c d s / 1 o ad f r en c h /user cmds/loaderrors-

— 853-

if eq #1 1 goto davel if eq #1 2 goto dave2 g o nop

tvpe starting dave J

chattr /dave/davelchec. s=-b

dave I's devices

videc D1aver

sttv baud * =9*b00 term2 sttv -etab -ers -ed i —echo -edit --.r.acc," tterrnl

/ d a v e / d c ' •' 22 -1 " t er fi.2 '•-■

sttv baud=4c_,00 bits-/ stop- ρar * =ever. lterm_. stt --etab —ers — edej --echo -edi — maocr tet'iTi. /dave/ touch 23 "term3 "

— —

"' pLfmp and bulloch

stty -oflow baud+4800 bits=7 sopt=2 par=even >$term4 stty -etab -ers —edel -echo -edit -mapcr >Φterm4

stty —o low baLtd—1200 bits=7 stoρ=2 par—even >^termS stty- —etab —ers —edel —echo —edit —mapc'-- >$terιsb /dave/pump 24 Φterm4 ΦtermS h. /dave/bulloch ΦtermS 28 £term4 h.

,f clave

/dave/dave 1 #2 §. jO-to nop

;dave2 type starting dave

dave 2's devices

video player

stty -ttermS stty —etab -ers -edel -echo —edit --mapcr * £term5

/dave/dc9 25 .-. " termS h

touch screen

__Λ i -7 _."•._ i id — -I _ !'.• ' !.. i l " / . i ,-,-t ,' i ., * -rn ιiιi I L. •_'' -' '>1r.. stt - etab -ers — edel -echo edit -mapcr iter.τ.6

pump

stty -oflow baud=4800 bιts=7 s op =2 par=even : *terrn7 stty -etab —ers — edel -echo --edit -iiiάpcr' term 7 / d a -rf e .' p rr. p 2 " ' 1 t e r >r.7 h

/ d a .- ε- - d a •■ e _.' .12 •_.

II -V

-S6i-

/user cmds/loadstart

/user cmds/load frame al

/user ciTids/ooen screen

/user_cιτ.ds/disρl yf 1 el

/user_cmds/oρen_screen 2

/user_cmds/di ρlayf 2 al

/user cmds/disDlayf 2 el

/user cmds/load bits

/user cmds/loader.gi1sh

/ussr_.cmds/load_frame a2 /user_cmds/load_frame a4 /user_ . cmds/load_frame aά> . μse _ cmds/1oacl_frame a8

' ' i = eι" _c >~.ds/l oad_-! r δ.Ti ' a!2

.'Lιser_c.τιds/1 oad_ rame al4

/ use ..c.Tids/ 1 oad_f rame ai ά.

/user_c.τιds/l oad_ rame alS

/Ltser_c.r.ds/1 oad_f rame a20

/Liser_c.τιds/lαad_f rame a20c

/ s- 'i ~ __c .T.d ε / 1 oad _-t r ams- a22

•'user , ends/ i. oa . fr a.rιι_". α <_>

/ uEfit ffidS ' J. Oad i άiiif ύ_i-t

/user cmds/1oadsrror

/ώser_cmds/lαad_frame sp_ll /user_cmds/load_frame εp_llf /user_cmds/load_frame sp_13 /user_c.τιds/load_frame sρ_13f

/user_c.πds/1oa.d fra._τ_s sρ._ l-z-

/-user _cmd s/ 1 oad _f r ame sp _ 15f /user _cmd / l'oad_f rame εp _ 16 /user_cmds/load_f rame sρ_l- f 'user_cmds/load_ rame sρ_17 t.ser_cmds/load_f rame sp_17f /lιser_cmds/load_f rame sp_2 /user_cmds/ 1 oad_f rame sρ_21 ' Liεer_c.τιds/1 oad _f rame sρ_21 /user _cmd s/1 ad _ rame sp_22 /Liser_cmds/load_f rame sp_22f /user_cmds/l oad_ r ame sp__ 2f /user_cmds/l oad_ rame sρ_ 5

/ use i' _cmds/ 1 oad t r e sρ__.ιf

/ user. _c.τιds/ i oao tr e sρ_6

/ user _c ds/ 1 oad _-F rame sp __ -f /user_cmds/load_f rame sp. 7 /user_cmds/l oad_ rame sρ_7f /user_cmds/lαad_f rame sp_8

/user_cmds/l oad _.f rame sp_. ul 1 /user_cmds/load_f rame sρ_half

_S£€-

'Liεer_ cmds/loadf rench

/Ltser_cmds/load_f rame a3

/user_cmds/load_f rame a5

/user_cmds/load_f rame a7

/ LI ser'_c. T.d s/ 1 oad_f rame a9

/ user _ m _-. loa ._f -ame all

/user _c iT.d s/ 1 oad_.f r ame a 13

/user_cmds/l oad_f rame alΞ

/user_cιτιds/l oad_f rame al7

/user_cmds/lαad_f rmae al9

/uεer_cmds/l oad_f rame a21

/ Liser _cmd __>/ 1 oad _f rame a21 c

/user _ ' cmds/ 1 oad_f rame a23

/user_ciTids/l oad_f rame a23a

/user cmds/load frame a25