DISTRIBUTED PROCESSING SYSTEMS INCORPORATING A PLURALITY OF CELLS WHICH PROCESS INFORMATION IN RESPONSE TO SINGLE EVENTS

Abstract: A distributed processing system (10) includes a plurality of cells (12, 14, 16, 18, 20) where each cell processes information in response to a type of event, and cells communicate with each other according to an (asynchronous) event-reaction protocol. According to one embodiment, each cell is responsive to a single type of event and includes a plurality of scripts (12a, 14a, 16a, 18a, 20a) which are executed upon the occurrence of an event of the appropriate type. At least some scripts include directions to send information to one or more scripts in another cell. According to another embodiment, some cells communicate with other cells according to a (synchronous) streaming protocol and other cells communicate according to an (asynchronous) event-reaction protocol. The cells communicates protocol utilized by the cells enables the use of virtually any networking medium. Thus, cells may reside in the same chip or may be separated from each other by thousands of miles.

Description: DISTRIBUTED PROCESSING SYSTEMS INCORPORATING A PLURALITY OF CELLS WHICH PROCESS INFORMATION IN RESPONSE TO SINGLE EVENTS This application is related to Serial Number 09/004,174, filed January 7, 1998, and entitled "Event-Reaction Communication Protocol in an Object Oriented Processor Array", the complete disclosure of which is hereby incorporated by reference herein. BACKGROUND OF THE INVENTION 1. Field of the Invention The invention relates to distributed processing systems. More particularly, the invention relates to distributed processing systems which incorporate a plurality of processing zones (referred to herein as "cells"), each cell processing information in response to a type of event, and each cell communicating with other cells according to an event-reaction protocol as well as according to other protocols such as streaming, broadcast, etc.. Cells exhibit a symmetrical and reciprocal relationship, with cells sometimes being a controller of other cells and sometimes being controlled by other cells. The system is self-configuring, self-repairing, and operates in real time. 2. State of the Art So-called "distributed processing" or "parallel processing" systems generally employ multiple processors in order to speed the execution of a single program or to enable the simultaneous execution of several programs. Distributed processing embraces almost any computing system where processing of data occurs in more than one CPU. A simple example of distributed computing is printing from a PC to an image processing printer which has its own processor. The task of printing is distributed between the processor in the PC and the processor in the printer. In almost every case of "distributed processing" or "parallel processing" the distribution of tasks is controlled by a central controller processor. Thus, while processing may be distributed, "intelligence" is not distributed. The "intelligence" to decide how processes will be distributed remains centralized and limited. U.S. Patent Number 5,095,522 to Fujita et al. discloses an object-oriented parallel processing system which utilizes "concept objects" and "instance objects". The system utilizes a host processor and a plurality of general purpose processors which are programmed by the host processor. The host user must program (generate concept and instance objects) for each processor before parallel processing can begin. Fujita et al. considers this aspect of their system to be a feature which allows dynamic changes in the functionality of each of the processors However, this aspect of their system greatly complicates the host processor software Similarly, U S Patent Number 5,165,018 to Simor descπbes a system in which ' nodes" are provided with geneπc configuration rules and are configured at runtime via resource definition messages from the control node Simor considers this aspect of his system to be an advantage which, among other things, "isolates the hardware from the software' and "allows programs to be wπtten as if they were going to be executed on a single processor " In addition, Simor's system permits programs to be "distributed across multiple processors without having been explicitly designed for that purpose " Both Fujita et al and Simor utilize general purpose processors and attempt to isolate the hardware from the software, freeing the programmer to write code as if it were being executed on a single processor However, as mentioned above, wπting multithreaded software for a single processor is very complex Neither Fujita et al nor Simor offer any solution for this complexity 3. Related Inventions Co-owned prior application Serial Number 08/525,948, now U S Patent Number 5,708,838, approaches the problem of distπbuted processing in a manner which is completely different from that of either Fujita et al or Simor The system disclosed in the '948 application utilizes processors which have been pre-programmed with functionality for a specific purpose and thereby integrates hardware with software The developer chooses specific hardware (object oriented processors) in a manner similar to choosing specific software objects This approach requires that the developer be very aware of the hardware used in the system, but frees the developer from wπting much of the code used to implement the system Accordingly, the developer need only wπte a minimal amount of relatively high level code to link the preprogrammed object oπented processors which contain statically stored code for performing specific tasks and to parametπcally program the processors where desired This approach is based on the belief that writing and de-buggmg code is more time consuming and more expensive than linking together processors which contain pre-wπtten, pre-tested, bug-free code This approach enables rapid system development, relieves the host processor of many scheduling tasks, simplifies de-buggmg, enables cross-platform support, and allows software emulation of hardware devices, as well as providing other advantages Co-owned prior application Serial Number 08/683,625, now U S Patent Number — discloses a distπbuted processing system where one or more object oriented processors are embodied as a collection of components on a single ASIC chip. This related application includes an enhanced communication language where messages from one processor to another include source and destination addresses. This communication protocol can be said to be "event driven". Co-owned prior application Serial Number 09/004,174, now U.S. Patent Number , discloses an object oriented processor array including a library of functional objects which are instantiated by commands through a system object and which communicate via a high level language. Communication is based on an "event-reaction" model. According to the event- reaction model, when a processor object has a message to send, it generates a data event which is registered with the target recipient of the message (usually the host). The target reacts to the event by allowing a variable amount of I/O exchange between the processor object and the target prior to an acknowledgement of the data event. According to one embodiment, until the data event is acknowledged, no other data event may be sent to the target. According to another embodiment, a fixed number of data events may be pending simultaneously. In one embodiment of a multi-node system, each node (each object oriented processor array) is aware of network traffic; and data events related to a particular target (host) receiver are registered with all nodes which have that receiver as a target as well as with the target. The number of data events which may be simultaneously pending at any time is determined by the target and known to each of the nodes. The target arbitrates the flow of messages based on the registration of data events. SUMMARY OF THE INVENTION It is therefore an object of the invention to provide a distributed processing system which is particularly well suited for processing information in real time. It is also an object of the invention to provide a distributed processing system which is relatively easy to program. It is another object of the invention to provide a distributed processing system which is self-configuring It is yet another object of the invention to provide a distributed processing system which is self-repairing. It is also an object of the invention to provide a distributed processing system wherein additional processors added to the system are automatically integrated into the system. In accord with these objects which will be discussed in detail below, the distributed processing system of the present invention includes a plurality of cells where each cell processes information in response to a type of event, and cells communicate with each other according to a variety of protocols including an (asynchronous) event-reaction protocol. Processing is truly distributed in that no cell is considered the system host or system controller. The cells exhibit a symmetrical and reciprocal relationship with cells sometimes being a controller of other cells and sometimes being controlled by other cells. According to one embodiment of the invention, each cell is responsive to a single event and includes one or more scripts which are executed upon the occurrence of the event. At least some scripts include directions to send information to one or more scripts in another cell. According to another embodiment of the invention, information exchanged between cells is categorized into the following types which are listed in descending order of priority: streams, data events, data event acks, spawn process, spawn process begun, spawn process ended, exception, and broadcast. The cells of the invention may communicate with each other via a shared memory or via a communications bus. A scalable bandwidth bus such as that described in co-owned previous application Serial Number 08/645,262, filed May 13, 1996. now U.S. Patent Number 5.922.061. is an ideal communications path for the cells of the invention. However, the communications protocol utilized by the cells enables the use of virtually any networking medium. Thus, cells may reside in the same chip or may be separated from each other by thousands of miles. According to the invention, a collection of interacting cells is referred to as a colony, regardless of where the cells are located, and a collection of cells which are closely located, e.g. on the same board, are referred to as a node. The modularity and scalability of the processing systems of the invention is therefore based on collections of cells and collections of colonies. According to the invention, each cell may be embodied in hardware, software, or a combination of hardware and software. No cell or colony need be considered a "host". In the preferred embodiments of the invention, each cell is provided with a collection of synchronous (non-colliding) scripts which respond to a single type of event. All scripts have addresses and the addresses of all of the scripts in the processing system are kept in a database by a resource manager script in each cell. Applications are created by linking available scripts via their respective addresses. As all scripts are driven by particular events, the code written for the distributed processing system of the invention does not require My explicit scheduling. The processing system is essentially self-scheduling and real time applications can run concurrently without mterfeπng with each other According to one preferred aspect of the invention, scπpts communicate with each other by dynamically compiling and teaπng down mailing lists which are based on the occurrence of specific events Thus, in response to one specific event, a responding scπpt will communicate with one set of other scπpts, whereas in response to a different event, the responding script will communicate with a different set of other scπpts Scripts subscribe to and unsubscribe from the mailing lists of other scripts based on the occurrence of different events According to another preferred aspect of the invention, cells advertise their presence in the network when connected, and peπodically thereafter, in order that other cells be able to take advantage of their resources In particular, each cell periodically (e g every second) updates its database of scπpt addresses which represent the functionality of the system to accommodate the addition of new cells to the system and to accommodate for cells which have become disconnected from the system or which have stopped functioning for some reason Thus, a processing system according to the invention is readily expanded to include new and additional processing resources which are substantially automatically assimilated into the system The processing system is, in this sense, self-configuπng and self-repairing According to another preferred aspect of the invention, communication among cells is effected with the aid of maihng lists such that data may be multicast from one cell to many cells Moreover, the mailing lists are preferably dynamically set up and torn down depending on the execution of scπpts which direct the flow of data throughout the system Further, the mailing lists are updated as new cells are added to and old cells are removed from the system as part o{ the self-configuπng and self-repaiπng functionality of the system An exemplary embodiment of a distributed processing system according to the invention is dlustrated with reference to a telephone pπvate branch exchange (PBX) in which cells are distπbuted over "line cards' and "phone cards" which couple several telephone sets to one or more telephone subscπber lines In this example, the cells communicate with each other via the same physical medium through which the telephones are coupled to subscπber lines Each line card and phone card is considered a node, each having a number of cells Cells in the phone cards include, for example, cells responding to the following events phone off hook, DTMF tone dialed, ring detected, etc Examples of scπpts executed in response to events include, generate dial tone, send πnging signal, seize subscπber line, etc According to a preferred embodiment, each of the cards advertises its presence to the other cards on a regular basis The knowledge of the presence of cards (nodes) in the system is used to build mailing lists when, for example, a conference call is made, or when the system is programmed so that only some phones in the system ring when an outside call is detected by a line card. Additional objects and advantages of the invention will become apparent to those skilled in the art upon reference to the detailed description taken in conjunction with the provided figures. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a high level schematic diagram of a local node of cells coupled to two remote nodes via an external bus; Figure 2 is a high level schematic diagram illustrating the lines of communication among scripts in a processing system according to the invention; Figure 3 is a high level schematic diagram of the buffering of messages between scripts and the network interface cells; Figure 4 is a flow chart illustrating the processing of messages by a network interface receiver cell; Figure 5 is a flow chart illustrating the processing of messages by a network interface transmitter cell; Figure 6 is a high level schematic diagram illustrating the flow of messages from cells across the network to other cells; Figure 7 is a high level schematic diagram of a distributed processing system according to the invention illustrated with reference to a telephone private branch exchange (PBX); and Figure 8 is a simplified flow chart illustrating a simple operation of the PBX of Figure 7. BRIEF DESCRIPTION OF THE APPENDIX The Appendix is a collection of program listings in C language source code for implementing the PBX described herein. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Referring now to Figure 1, a distributed processing system 10 according to the present invention includes a plurality of cells (or processing zones), e.g. 12, 14, 16, 18, 20. Each cell is responsive to a particular event and responds to the event by executing one or more scripts. For purposes of illustration, the cells 14, 16, 18, 20 shown in Figure 1 are each depicted as having four executable scripts 14a-d, 16a-d, 18a-d, 20a-d. For reasons explained below, the cell 12 has only one script 12a. Further, for purposes of illustration, each cell is shown to have a "dispatcher" 12e, 14e, 16e, 18e, 20e which interprets the event and causes scripts to be executed in response to the event. The cells 12, 14, 16, 18, 20 shown in Figure 1 are related to each other spatially and are conveniently referred to as a "node" which is delineated by the box 22. The cells 12, 14, 16, 18, 20 in the node 22 are coupled to each other by either a bus or a shared memory or other communications means which is described in more detail below with reference to Figure 2. As shown schematically in Figure 1, data enter and leave cells via buffers 12aB, 12eB, 14aB, 14cB, 16eB, 18bB, 18eB, 20aB, 20eB. The spatially related cells in node 22 may be coupled to cells in other remote nodes 24, 26 by way of an external bus 28. As mentioned above, a collection of cells which interact with each other is referred to as a colony, regardless of the physical location of the cells. As illustrated in Figure 1, cells 16, 18, and 20 are respectively responsive to a particular. locally perceived, external event 30, 32, 34. Examples of such events include keypad inputs, switch positions, ADC signals, etc. Thus, for example, a keypad event 30 is interpreted by the dispatcher 16e which triggers one or more scripts 16a-16d depending, for example, on which keys are pressed. According to the example illustrated in Figure 1, the cell 14 is a "network interface receiver" and is responsive to message events received via the external bus 28. In particular, if a cell in a remote node, e.g. 24, 26, executes a script which sends a message to a script in one of the cells in the node 22 it is received by the dispatcher 14e in the cell 14 and is forwarded to the appropriate script(s). An exemplary embodiment of a network interface receiver can be found in the Appendix at pages 45-57 (nicrx.c). In the example illustrated, the dispatcher 14e executes scripts such as 14c which sends a message to a local external output device 36 and script 14d which sends messages to scripts 18b and 20a. The type of message which might be sent by script 14d includes messages which alert scripts 18b and 20a that a recipient of their respective messages is ready to receive messages. The cell 12 shown in the illustrated example is a "network interface transmitter" and is responsive to a single script 12a which transfers messages from the node 22 to other nodes. An exemplary embodiment of a network interface transmitter can be found in the Appendix at pages 26-33 (nictx.c). The cell 12 is also responsive to clock signal events from a clock 38. In this example, the clock signal events cause the execution of script 12a which transmits messages according to priority to remote nodes via the bus 28. As described above, messages may be transmitted according to an event-reaction protocol or according to a streaming protocol. For example, as described in more detail below, scripts executed in cell 20 in response to input from an ADC 34 may generate streaming data which is communicated to a cell 12 for transmission to a remote node via the external bus 28. Communications among scripts is preferably effected via structured communications packets of variable length which includes address information, an indication of the message type, an indication of the message length, and the message. A presently preferred packet structure is illustrated in Table 1 below. Table 1 As shown in Table 1 , in addition to having a variable payload length, the packet structure includes a variable field length for recipient addresses. According to the packet structure shown, each script has the capability of multicasting a message to up to eight other scripts, each having a two byte address. Indeed, as will be described in more detail below with reference to Figure 5, according to preferred embodiments of the invention, scπpts build mailing lists based on events such that the recipients of the messages generated by a particular scπpt will change over time According to a presently adopted convention, messages are broadcast to all scπpts by indicating that the length of the recipient address listing is 0, by not listing any recipient addresses, and by indicating the message type as being "broadcast" The presently preferred address format is two bytes where the first byte indicates the node where the scπpt resides, three bits identify a "subnet", and five bits identify the scπpt In presently preferred embodiments, "subnet" refers to a single transport medium through which multiple nodes communicate This addressing system provides the foundation for allowing groups of nodes in different networks to communicate with each other provided that there is some way to bπdge the different networks According to a presently implemented embodiment which is descπbed in more detail below with reference to Figures 6 and 7 and the Appendix, the payload is limited to sixty-four bytes Those skilled in the art will appreciate, however, that the maximum size of the payload depends in part on the type of application being implemented, the bandwidth of the network, as well as the latency which can be tolerated by the application According to the presently preferred embodiment, eight message types are defined These include "broadcast", "exception", "remote process spawn", "remote process begun", "remote process ended", "data event", "data event acknowledge", and "stream" The payload types presently defined include "unsigned character", "signed character", ' unsigned integer", "signed integer", "μ-law encoded", "wave encoded", and "MPEG encoded' The message type field is used by queue managers to dispense rank tokens in order to pπoπtize packets Further, the message type field may be used by scripts to determine whether the receiving scπpt is intended to operate in either a ' master mode' or a "slave mode Turning now to Figures 2 and 3, each script in a node is coupled to a "local bus" 40 For purposes of this description, the "local bus" 40 is referred to as the Imf (internal message format) bus and in a presently preferred embodiment it is embodied as a multiported shared memory If a shared memory is not used, it is preferred that the Imf be provided with buffers foi mter-cell communications within a node and mter-node communications Regardless, each script which has a need to output a message through the network interface transmitter 12 or receive a message from the network interface receiver 14 is provided with a buffer for mter-node communications Each buffer is presently embodied as an instance of a data structure (e.g 16aB, 14aB, 18aB, 14nB, etc. in Figure 3) which includes routing information for the network interface transmitter and receiver, feedback to the sending scπpt about the status of the receiving scπpt's state, and any information which may have been returned by the receiving scπpt In addition, the buffer includes all information needed for the network interface transmitter dispatcher 12e to packetize the outgoing message and for the network interface receiver dispatcher 14e to route the incoming message. Thus, messages entering a node through the network interface receiver dispatcher 14e are automatically routed by the network interface receiver via a function call to a pointer which points to a script in an "IMF STRUCT" array associated with the network interface receiver. These arrays are defined throughout the Appendix and called "Scripts [...]". Moreover, automatic responses to messages such as spawn process requests are similarly created. A high level description of how the network interface receiver and transmitter utilize these buffers is illustrated in the flow charts of Figures 4 and 5. Referring now to Figure 4, when a message is received by the network interface receiver, after examining the message contents and checksum, the node and subnet address information is extracted at 100. The script address is read at 102. According to a presently prefeπed embodiment, the script address points to a pointer in the IMF struct. The IMF struct is read at 104 and the pointer to the script is obtained. Using this pointer the actual script is found at 106. The remaining information in the message is passed to the script at 108. If the message is the type which requires a reply, the reply info is obtained from the script at 110 and the previously extracted address info is used at 112 to return the reply to the sending script. Other details of a network interface receiver according to the invention can be gleaned from the source code listing "nicrx.c" in the Appendix at pages 45-57. Turning now to Figure 5, messages leaving the node via the network interface transmitter are processed according to a queue. The queue contains pointers to the buffers (e.g. the IMF STRUCTs in Figure 3) containing outgoing messages. The pointer to the next message is read from the queue at 200 and the message type is read from the buffer at 202. The address length and address fields are adjusted according to the message type at 204. For example, if the message type is broadcast, the address length field is set to zero and no addresses are listed. Similarly, if the message type is a data event ack, the address length will be two bytes since these messages always have one receiver. However, if the message type is a data event or a stream, there may be many addresses. According to the presently preferred embodiment, data events require acks and the acks are used to update mailing lists, but streams do not require acks. If the message type requires a response, ack flags are set at 206 so that when acks are received they will be registered as described above. At 208, the packet with the checksum is constructed and at 210 the transmitter is informed that a new message is ready to be sent. According to the presentiy preferred embodiment, the constructed packet is held in a buffer and a pointer to the buffer is held in the output message queue. This constitutes the basic handling of messages by the network interface transmitter. Other details of a network interface transmitter according to the invention can be gleaned from the source code listing "nictx.c" in the Appendix at pages 26- 33. As will be seen in the Appendix, the output message queue is presently limited to eight IMFstruct pointers. As mentioned above, according to the invention, scripts may communicate with each other by dynamically compiling and tearing down mailing lists which are based on the occurrence of specific events. For example, with reference to the general discussion regarding Figures 1-5, one of the byproducts of a remote process spawn message may be the updating of a "mailing list" which is referenced by data event messages and stream messages. Also, as mentioned above, according to another preferred aspect of the invention, cells periodically advertise their presence in the network so that other cells can take advantage of their resources. For example, with reference to the general discussion regarding Figures 1-5, cells or nodes may be programmed to periodically send broadcast type messages to announce their presence in the network and their capabilities. The cells or nodes would also then be programmed to interpret such broadcast messages and update mailing lists and databases based on these messages. An example of messages exchanged in response to an advertisement from a cell is illustrated with reference to Figure 6. As illustrated in Figure 6, the cell 42 in node 24 learns from an advertisement that the cell 44 in node 26 is now connected to the network and is functioning. From its own programming and the advertised information, the cell 42 knows that the cell 44 is responsive to input which is useful to the activity of cell 42. In response to this information, the script 42a in cell 42 creates a "remote process spawn" message which is directed to the script which manages the mailing list of cell 44. The spawn process message is a directive to add addresses to the mailing list of scripts in the cell 44. The message flows via the local bus (not shown) to the network interface transmitter cell which transmits the message via script 46a onto the network 28. Once the message is transmitted onto the network it is seen by all network interface receiver cells which are coupled to the network. The "to address" in the message is read by all receivers including the network receiver 48 in node 26. Based on the address and the message and the message type, the dispatcher 48e in cell 48 executes script 48a which is responsible for managing the mailing list 52 of the cell 44. The mailing list 52 resides in shared memory or in a buffer dedicated to that purpose. Preferably the mailing list resides in a buffer which is only visible to the cells involved. The script 48a reads the message from script 42a, determines that the message is intact, checks the mailing list 52 to determine whether the "new subscriber(s)" is already on the list and updates the mailing list 52 if needed. Based on a recognition of the message type, the script returns a message to script 42a that the remote process is ended. The "remote process ended" message includes error indications if any errors were encountered during execution of the process. The update mailing list is a fast process and, as such, does not require the "remote process begun" response. In the case of processes which take longer times to complete, the script performing the remote process preferably will respond that the process has begun and will respond again that the process is ended. When the event "X" occurs at the input cell 44, the dispatcher 44e calls script 44a which sends a message to the network interface transmitter 50. The cell 44 may process the event first or may simply call the script 44a to notify the transmitter. For example, if the cell 44 is a keypad controller, it will "process" the event "X" to determine which key has been pressed prior to calling the script 44a. The message sent by 44a will include the results of the processing, i.e. an indication of which key was pressed. Alternatively, if the external input to the cell 44 is one bit binary such as an on/off switch, the script 44a may always send the same message, i.e. switch has changed state, may be hard coded to do so, and thus may simply be called without first processing the event "X". The dispatcher 50e in the transmitter 50 recognizes that the type of message is a data event and calls the script 50a which gets the mailing list from the data structure 52 (based in part on the from address) in order to format the message for a multicast transmission onto the network 28. When the message is sent by script 50a, the script also enters information in the buffer (not shown here, but see Figure 3) associated with the cell 44. The information includes an indication that data was sent to the members of the mailing list. This information will later be used to be sure that the data was received intact within the allocated time frame, i.e. to determine whether the data needs to be resent to one or more recipients. The message from the transmitter 50 is found on the network 28 by all of the receivers coupled to the network. All of the receivers read the node information in the address list to determine whether any cells in their respective nodes contain affected scripts. For example, if the address contains the node, the dispatcher 54e in the network interface receiver 54 routes on the script address to call the appropriate script 54a to process the message. The script 54a may be designed to take the data payload of the message and store it at a location in the shared memory 56 of the node 24. Alternatively, the script 54a may be designed to take the data payload of the message and store it at a location in the shared memory 56 and also call another script which will read the data from shared memory and make use of it. The example illustrated in Figure 6 illustrates the symmetrical/reciprocal nature in which the cells function. In this example, a cell in node 24 began by spawning a process in node 26 to add its address to the distribution list of a cell in node 26. In this manner, the cell in node 24 was acting as a "master" and the cell in node 26 was acting as a "slave". Later, when the "event X" cell detects the event X, the event X cell in node 26 acts as a master and the cell(s) in node 24 act as slave(s). This is markedly different from classical multi-processing systems where one processor always acts as the instigator of activities The general descπption of processing systems described above may be better understood with reference to a specific application of the system (although it is not limited thereto) A prototype application has been developed implementing the architecture descπbed generally above in a telephone pπvate branch exchange (PBX) in which cells are distπbuted over "line cards" and "phone cards" which couple several telephone sets to one or more telephone subscriber lines Turning now to Figure 7, a distπbuted processing system 300 according to the invention is embodied as a telephone private branch exchange (PBX) The system 300 includes a plurality of line cards 302, 304, 306, each of which is coupled to a separate subscπber line 308, 310. 312 and a plurality of phone cards 314, 316, 318, 320, 322, 324, 326, each of which supports one telephone set or similar device 330, 332, 334, 338, 340, 342, 344 According to the presently preferred embodiment, the line cards and the phone cards are each powered by their own power supply which is an AC adaptor coupled to the AC mains of a home or office The line cards 302 and 306 are coupled to their respective subscπber lines 308 and 312, but are not coupled to anything else The line card 304 is a hybrid line card/phone card and is coupled to subscriber line 310 as well as to telephone set 336 The phone cards 314, 316, 318 are each coupled to the subscπber line 308 and, as explained in more detail below, are able to communicate with each other and with the line card 302 by sending signals over the subscπber line 308 wires The phone cards 320 and 322 are coupled to the subscriber line 310 and, as explained in more detail below, are able to communicate with each other and with the hybrid card 304 by sending signals over the subscriber line 310 wires Phone cards 324 and 326 are coupled to the subscπber line 310 and, as explained in more detail below, are able to communicate with each other and with the line card 306 by sending signals over the subscπber line 312 wires In order for cards coupled to subscπber line 308 to communicate with cards coupled to subscπber line 310, a bridge 346 is provided and coupled to both subscriber lines 308 and 310 The bridge 346 allows signals generated by the cards to be received over both subscπber lines but does not couple the subscπber lines in a way which would interfere with their use in the telephone network Similarly, subscπber lines 310 and 312 are coupled by a bridge 348 which allows the cards coupled to subscπber line 312 to communicate with the cards coupled to subscriber lines 308 and 310 According to a preferred aspect of the invention, the network may be bridged over different media For example, using a bridge 350, the network can be expanded onto the AC mains 352. It will be understood that on the mains medium, a slightly different interface will be required for the phone card 354 which coupled telephone set 356 to the entire PBX 300 According to the presently preferred embodiment of the invention, bπdging of like media is done with a capacitive or inductive bndge and bπdging of dissimilar media is done with a "smart bπdge". It will be appreciated, however, that a smart bπdge could be used to bπdge like media as well. Applying the general descπption of Figures 1-6 to the example of Figure 7, each of the line cards and phone cards may be thought of as a separate node and the bridged subscriber lines and AC mams may be thought of as the network bus 28 shown in Figures 1 and 6 The cells in each line card include a cell which responds to events occurring on its associated subscπber line, i.e., an incoming phone call Scπpts responding to an incoming phone call include πng detection, ring mailing list, and caller LD mailing list Other scπpts which respond to scπpts from the phone cards include line seize, dial, and speech mailing list The ring mailing list and the caller ID mailing list indicate which phone cards will receive a πng signal and caller ID information when a ring is detected on the subscriber line by the line card The line seize and dial scπpts respond to messages from a phone card when certain scripts in the phone card are executed The speech mailing list scripts which exist on both the phone cards and the line cards control the delivery of streaming digitized sound The phone cards each include scripts which respond to events generated by the attached telephone set and to messages received from the other cards in the network For example, the phone cards include scripts for generating a dial tone when the attached telephone set goes off hook, for registering DTMF tones, for sending messages to other cards in the system, etc The attached Appendix includes code for implementing line cards and phone cards The code which is particular to the line cards is identified by file names which begin psn/lc' and can be found in the Appendix at pages 60 through 87 The code which is particular to the phone cards is identified by file names which begin "phone/" and can be found at pages 87 through 173 of the Appendix Code which is used by the system generally and by both the phone cards and the line cards is found in the Appendix at pages 3 through 60 For example, when the telephone set 332 goes off hook, the off hook event causes a seπes of scπpts to be executed m the phone card 316 which generate a dial tone for the telephone set 332 When a digit is dialed, another scπpt is executed to register the DTMF tones, etc. Figure 8 illustrates some of the functions of the PBX system 300 Turning now to Figure 8, when a telephone set attached to one of the phone cards in the system goes off hook, an "off hook event" is detected by a cell in the phone card and this is indicated at 400 in Figure 8. This event is also illustrated in the Appendix at pages 82 et seq. Given the parameters of the network bandwidth and the number of cards attached to the network, it is possible that there will not be enough bandwidth available to service the telephone set and the phone card will generate a busy signal. Otherwise, the phone card will generate a dial tone as indicated at 402 in Figure 8 and as also shown in the Appendix at pages 159 et seq. It will be appreciated from the Appendix that the dial tone heard in the telephone set is not the dial tone generated by the public telephone network but is a tone generated by a cell in the phone card. See Appendix pages 41-42. However, it will be appreciated that the telephone network dial tone could be used. The telephone set will next generally generate a DTMF tone in response to a user pressing a key on the keypad. When this occurs a "dial digit event" is detected by a cell in the phone card as indicated at 404 in Figure 8 and in the Appendix at pages 64 et seq The cell which detects DTMF tones coming from the telephone set includes scripts for time out limits between digits, a script for stopping the generation of dial tone (406 in Figure 8) and scripts for recognizing which DTMF digits were dialed. According to a preferred embodiment, the PBX system allows calls to be made between phones in the local network without using the public telephone network. Thus, the DTMF cell in the phone card will contain scπpts to interpret whether the digits dialed represent an outside call which requires the use of a subscriber line. This determination is illustrated at 408 in Figure 8 and in the Appendix at pages 141 et seq. If the call needs an "outside line", messages are sent from the phone card to the line card(s) as illustrated at 410 in Figure 8 These messages include a request to seize a line and a request to dial the number corresponding to the digits dialed by the telephone set. See Appendix pages 101-104 (request to seize a line) and pages 1 17 et seq (request to dial digits). Though not illustrated in Figure 8, it will be appreciated that these messages to the line card are remote process spawn events which require a response from the line card. Thus, as seen in the Appendix at pages 81 et seq., the line card seizes a subscriber line and dials the DTMF tones. In addition, streaming data will be sent from the phone card to the line card and vice versa for the sound/speech of the telephone call. Each card has a speech cell and, as shown in the Appendix at pages 71 et seq. (line card) and 93 et seq. (phone card), the speech cells each have a mailing list which is edited whenever a connection between phones is made. From the foregoing and the Appendix, it will be appreciated that conference calls are easily enabled via the use of mailing lists. See, e.g., Appendix pages 51-55 and 93 et seq. Returning now to Figure 8, if it is determined at 408 that the number dialed is a local network number, e.g. an extension number, a script is executed (412 in Figure 8) to look to the network database to determine if there is a phone card responding to that extension number connected to the network. See Appendix pages 141 et seq. If no such number exists as determined at 414 in Figure 8, a speech generating script is called to generate an audio message at 416 in Figure 8 which is heard in the hand set of the telephone. According to the presently preferred embodiment, speech generation tools are used throughout the system to generate "recorded" messages. See, e.g., Appendix pages 137 et seq. which shows how messages are constructed by concatenating pre-recorded words and phrases. If it is determined at 414 in Figure 8 that the dialed extension exists, a message is sent at 418 in Figure 8 to the phone card having the extension number dialed. This is also illustrated in the Appendix at pages 142 et seq. If the phone connected to the dialed phone card is not off hook, a script in the dialing phone card will generate a ringing tone in the handset of the dialing telephone. This is illustrated at 420 in Figure 8 and in the Appendix at page 143. Meanwhile, a script will send a message to the dialed phone card instructing it to make the phone attached to it ring. The dialed phone card will return information indicating whether the dialed phone has picked up. Though not shown in Figure 8, this is illustrated in the Appendix at 122 et seq. Once the telephone being called has gone off hook, the ringing is stopped and the mailing lists for the speech streaming messages on both phone cards are updated. This is generally shown in the Appendix at pages 93 et seq. Though not illustrated in Figure 8, it can be easily appreciated from the Appendix that whenever either the caller or the called hangs up, a message is sent to update the mailing lists of the two phone cards, i.e. to remove the addresses of each phone card from the mailing list of the other with regard to speech streams. See, e.g., Appendix at pages 170 et seq. From the forgoing, those skilled in the art will appreciate that the PBX system described above may also be adapted to network other types of data in addition to or in lieu of telephone calls. For example, given the principles of the invention, it is possible to adapt the PBX network described above to also carry serial data streams from a personal computer to a printer, for example. This is also suggested in the Appendix at pages 35, 138, and 156. Moreover, it is possible to create phone cards which also have serial and/or ETHERNET ports so that the home subscriber line(s) wire(s) can be used for data networking. In addition, it is easy to realize, given all of the above disclosure that the invention may also be adapted to carry various types of home automation, home security, and home entertainment data. For example, other processing colonies according to the invention can be coupled to the home network (either telephone wires or AC mains, or even cable tv wires) with or without the PBX system. These other processing colonies can include video transmitters and receivers for both security .and entertainment, multiple digital sound channels for security and entertainment, simple signal controls to turn appliances on and off in response to events for both home automation and home security, etc. Though not yet fully implemented, it will be appreciated that the invention can achieve remarkable efficiency through the application of "space-time" programming where time is included in the declaration of variables and functions. There have been described and illustrated herein several embodiments of a distributed processing system incorporating a plurality of cells with each cell being responsive to a type of event. While particular embodiments of the invention have been described, it is not intended that the invention be limited thereto, as it is intended that the invention be as broad in scope as the art will allow and that the specification be read likewise. Thus, while particular a particular embodiment has been disclosed with reference to software, it will be appreciated that the invention may be embodied in software, hardware, or combinations of software and hardware. It will therefore be appreciated by those skilled in the art that yet other modifications could be made to the provided invention without deviating from its spirit and scope as so claimed. APPENDIX C Language SOURCE CODE phone/ph_sm_gl c phone/ph_pιns h phone/ph_sm_pt c ulaw c 3 phone/ fsl -out c display h 3 codec h phone/ph_tιmer c 3 uart h phone/ph_scrιpt c 4 ulaw h phone/ph_sm_pt h A prior b phone/ph_sm_gp h A phone/ph_sm_gp c strutils h 5 phone/ph_maιn h strutils c 5 phone/ph_maιn c nictx h 12 dbase c 12 dbase h 15 iσregs h 16 display c 16 t c 21 uart c 21 globals h 2 nictx c 26 zones h 33 nicrx h 3 defs h 34 spch c 36 nicrx c 45 spch h 57 codec c 58 psn/lc_tιmer h 60 psn/lc_scrιpt h 61 psn/lc_pιns h 61 psn/lc/timer c 62 psn/lc_maιn c 65 psn/lc_maιn h 69 psn/lc_scrιpt c 70 phone/remove c 87 phone/sιg_gen c 89 phone/sιg_vars c 90 phone/ph_scrιpt h 90 phone/ph_tιmer h 91 phone/ph_sm_sc h 91 phone/ph_sm_gl h 91 phone/ph_sm_ss h 91 phone/reLline c 92 phone/ph_sιπ_ss c 93 phone/ph_sm_sc c 96 phone/spch_seq c 100 Appendix Appendix LISTING ulaw c 1 #ιπclude "globals h" 2 3 #ιnclude "ulaw tbl" 4 5 ulaw ImToUOπt lιnValue)( £ /************************ 7 ιf(lιnValue<0)| 8 linValue—linValue; 9 ιf(lιnValue<0x1df0)) I 0 return lιn2u[lιnValue] Λ 0x7F; II I 12 else) 13 return 0; 14 I 15 I 16 elsef 17 ιf(lιnValue<0x1df0)| 18 return ~lιn2u[lιnValue]; 9 | 0 else) 1 return 0x80; 2 J 3 I 4 1 LISTING display h 1 void vfdlnitO; void moveEL(uchar row, uchar col); 3 void putsEL(uchar *text); 4 void putsLenEL(uchar *text, uchar len); LISTING codech 1 extern bit PecRefιll,PecOFIag,FιrstPkt; 2 extern bit CodecPostFlag; 3 extern ulaw CodecTxBuffA[SPCH_PKT_SIZE]; 4 extern ulaw CodecTxBuffB[SPCH_PKT_SIZE]; 5 6 void codeclnitO Appendix LISTING uart h 29 / TIMER3 Speech Processing 30 #define T3-.ILVL 4«2 #lf DEBUG-.OUT— UART 31 #defιne T3-.GLVL 0 void uartlnitQ, 32 void putsUart(uchar* text), 33 //TIMER2 Timer void putsUart2(uchar* textl , uchar* text2), 34 #define T2JLVL 3«2 void tickleUartQ, 35 #defιne T2_GLVL 0 36 extern uint UartTimer, 37 //Uart - for debug purposes #eπdιf 38 #defιne S0TJLVL 2«2 39 #defιne S0T..GLVL 0 LISTING ulaw h 40 41 //TIMER6 Display extern const int u2Lιn[], 42 #define T6JLVL 1 «2 extern const char near Iιn2u[], 43 #defιne T6_GLVL 0 ulaw lιnToU(ιnt ImValue), LISTING strutil LISTING prior h uint strLen(uchar* str), //EXT2 nicTxXfr- PEC3 uint strCat(uchar* strl uchar* Str2), #defιne EXT2JLVL 15«2 uchar* strCpy(uchar* strl , uchar* str2), #defιne EXT2_GLVL 3 uchar* formatDecUchar(uchar *pπntStr, uchar uc), uchar* formatDecUιnt(uchar *prιntStr, uint ui), //EXT4 nicRxXfr- PEC2 uchar* formatDeclnt(uchar *prιntStr, int si), #defιne EXT4JLVL 15«2 uchar* formatHexUchar(uchar *prιntStr, uchar uc), #defιne EXT4_GLVL 2 uchar* formatHexlπt(uchar *prιntStr, int i), uchar* formatHexLong(uchar *prιntStr, ulong i), //EXT7 CodecRx - PEC1 #defme EXT7_ILVL 14«2 LISTING strutil #defιne EXT7-.GLVL 1 1 #defιne uchαr unsigned char //EXT6 CodecTx - PECO 2 #defιne uint unsigned int #defιne EXT6_ILVL 14«2 3 #defιne ulong unsigned long define EXT6-.GLVL 0 4 5 uint strLen(uchar* str){ //EXT 5 EOM 6 /*****♦♦*♦»»**+**♦****♦/ #defιne EXT5JLVL 6«2 7 uint i, #defιne EXT5_GLVL 0 8 ι=0, 9 whιle(*str){ //EXT3 Combo Intrp 10 str++, #defιne EXT3JLVL 5«2 1 1 ι++, #defιne EXT3-.GLVL 0 12 } 13 return l , //TI ER5 NicRxDisp 14 define T5 LVL 4«2 15 #defιne T5-.GLVL 1 16 uint strCat(uchar* strl, uchar* str2){ 17 Appendix Appendix } uch /** } uch Appendix Appendix 1 1 2 prιntStr[2]-(uchαr)ιTemp+'0' ; 159 } 1 13 stαrtedFlαg«l; 160 1 14 } 161 ιTemp-sι/1000; 1 1 5 else{ 162 iffiTempl lstartedFlag){ 1 16 prιntStr[2]=' ' ; 163 sι--ιTemp*lø00; 1 1 7 } 164 prιntStr[2]=(uchar)ιTemp+'0' ; 1 1 8 165 startedFlag=l; 1 19 ιTe p=uι/lø; 166 } 1 20 ιf(ιTemp>0 II startedFlag). 167 else{ 121 ui—iTemp'10; 168 pπntStr[2]= ' ' , 1 22 printStr[3]-(uchar)iTemp+"0' ; 169 } 1 23 } 170 124 else{ 171 ιTemp=sι/100, 125 pπntStr[3]*' ' ; 172 ifCiTempl lstartedFlag){ 1 26 } 173 sι-=ιTemp*100; 1 27 174 prιntStr[3]=(uchar)ιTemp+'0' ; 1 28 prιntStr[4]-C"char)ui+'0' ; 175 startedFlag=l; 1 29 prιntStr[5]»0; //string term, 176 } 1 30 return prιntStr+5; 177 else{ 131 178 pπntStr[ 3 ]»=' ' ; 1 32 179 } 133 uchar* formatDecInt(uchar 'printStr, int sι){ 180 134 181 ιTemp=sι/10; 135 182 ιf(ιTemp>ø II startedFlag){ 136 This routine takes an unsigned char as argument and 183 sι-=ιTemp*10; 137 returns an ASCII format string 184 pπntStr[4]=(uchar)ιTemp+'0' ; 138 */ 185 } 1 39 int iTemp; 186 else{ 140 bit startedFlag; 187 prιntStr[4]=' ' ; 141 188 } 142 ιf(sι<0){ 189 143 prιntStr[0]-'-'; 190 pπntStr[5]=Cuchar)sι + '0' ; 144 si—si ; 191 prιntStr[6]»0; //string term, 145 } 192 return pπntStr+6, 146 else{ 193 147 prιntStr[ø]*' '; 194 148 } 195 149 196 uchar* formatHexUchar(uchar *prιntStr, uchar uc){ 1 50 ιTemp-sι/10000; 197 / * *** ***** * **** * ********* * * ** ****** * ** * * * ** *** * 1 51 ιf(ιTemp){ 198 1 52 si—iTemp*10000; 199 This routine takes an unsigned char as argument and 153 printStr[l]=(uchar)iTemp+'0' ; 200 returns an ASCII format string 1 54 startedFlag-1; 201 */ 1 55 } 202 if (Cue » 4) < 10){ 1 56 else{ 203 •printStr = (uc >> 4) + '0' ; 1 57 prιntStr[l]=' '; 204 } 1 58 startedFlag-0; 205 else{ Appendix Appendix ng term, ar 'printStr, ulong ι){ ************ * ********** takes an unsigned char as argument and SCII format string < 10){ (u c[n] » 4) + '0' (u.c[n] » 4) - 10 u c[n] + '0' ; u c[n] - 10 + 'A'; ng term, Appendix Appendix LISTING nictx h 34 } 35 } void postTxQueueOmfStruct* irnfPtr); 36 //If dBase full then the new data is ignored. void nicTxDispO; 37 #lf DEBUG_0UT==UART void nicTxlnitO; 38 else{ extern uchar NιcTxBuff[]; 39 putsUart("Warn- The service database is full\n"); extern uchar TxTimer; 40 extern bit TxPendiπgFlag; 41 } 42 #endιf extern bit PnvateFlag; 43 //Flip the polarity of foundFlag such that if an extern uchar PπvateNode; 44 //entry was made the func returns a one 45 return foundFlag'01; LISTING dbase c 46 } 47 #ιnclude ' globals h" 48 uchar dbDel(servStruct* s){ #ιπclude "defs.h" 49 *********** ************ • / tfi nclude "dbase h ' 50 uint c; #tnclude "uart h 51 bit foundFlag, 52 dbEntry dbase[MAX_DB-ENTRIES] ; 53 //Check to see if this entry is present uchar totalEntπes , 54 foundFlag=0; 55 f or(c- ; c<total Entπ es ; ++){ uchar dbAdd(servStruct* s){ /************************/ 56 ι f(dbase[c] dbs servιce«s->servιce){ 57 ιf(dbase[c] .dbs addr. node— s->addr.node){ uint c, foundFlag; 58 ιf(dbase[c] . dbs. addr. scrιpt=-s->addr scrιpt){ 59 foundFlag-d; //Check to see if this entry is already present 60 break; foundFlag=0; 61 } for(c»0;c<totalEntrιes;c++){ 62 } if(dbase[c].dbs.service—s->servιce){ 63 if(dbase[c] .dbs.addr.node—s->addr.node){ 64 } if(dbase[c] .dbs.addr. script ™ s->addr.senpt){ 65 foundFlag=l; 66 ιf(foundFlag){ break; 67 //Move up the last entry to fill the space occupied by the } 68 //deleted entry and then decrement "totalEntπes' . } 69 dbase[c] dbs service - dbase[totalEntries].dbs.service; } 70 dbase[c] dbs addr node - dbase[totalEntrιes].dbs.addr node; } 71 dbase[c] dbs.addr.script - dbase[totalEntrιes]. dbs.addr.script; 72 dbase[c] access » dbase[totalEntries].access; ιf(totalEntrιes < (MAX_DB_ENTRIES-1)){ 73 ιf(totalEntπes i =0){ //0 3 /31/98 10 58 am Safeguard to prevent ιf(foundFlag—0){ 74 "underflow' //Add service to dbase 75 totalEntπes-- , dbase[totalEntrιes].dbs servιce-s->servιce; 76 } dbase[totalEntries].dbs.addr.node-s->addr.node; 77 } dbase[totalEntrιes] dbs.addr.scrιρt-s->addr. script; 78 //Flip the polarity of foundFlag such that if an dbase[totalEntrιes].access=l; 79 //entry was not found func returns a one. totalEntrιes++; 80 return foundFlag'0:l; Appendix Appendix 81 } 128 foundFlag=l, 82 129 break, 83 uchαr dbSeαrchServιce(uchαr start, servStruct* s){ 130 84 ********************************************** * */ 131 85 //Starting from index - start' return the index at 132 86 //which the service can be found On entry s service } //is imtiased to the required service 133 87 } uint index, 134 ιf(foundFLag){ 88 for(ιndex=start, ιndex<totalEntrιes, ιndex++){ 135 dbase[c] access - access, 89 se[ιndex] dbs servιce=»s->servιce){ 136 90 ιf(dba } 137 //Flip the polarity of foundFlag such that if an 91 //s >servιce - dbase[ιndex] dbs service, 138 //entry was not found func returns a one 92 s >addr node « dbase[ιndex] dbs addr node, 139 return foundFlag'ø 1, 93 s->addr script ■» dbase[ιndex] dbs addr script, 140 94 return(ιndex), } 141 95 } 142 uchar dbReadAccess(servStruct* s){ 96 } 143 /* ****************************** * 97 return N0T_F0UND, 144 uchar c, 98 99 145 bit foundFlag , 100 uchar dbSearchAddress(uchar start, servStruct* s){ 146 //Check to see if this entry is present 101 *♦*♦*••***♦»*/ 147 foundFlag=0, / • ****+»**************»•****♦**♦*»* 102 //Starting from index - start return the index at 148 for(c=0,c<totalEntrιes ,c++){ 149 ιf(dbase[c] dbs servιce=-s->servιce){ 103 //which the service can be found On entry s service 104 150 ιf(dbase[c] dbs addr node— s->addr node){ //is imtiased to the required service 151 ιf(dbase[c] dbs addr scrιpt==s->addr scπpt){ 105 uint index, 152 foundFlag=l, 106 for(ιndex=start, ιndex<totalEntπes, ιndex++){ 107 ιf(dbase[mdex] dbs addr node=-s->addr node), 153 break, 154 108 } s >servιce - dbase[ιndex] dbs service, 109 //s >addr node - dbase[ιndex] dbs addr node, 155 } 1 1 0 s >addr script - dbase[ιndex dbs addr script, 156 } 1 1 1 return(ιndex), 157 } 1 1 2 158 ιf(foundFlag){ } 1 13 159 return (uchar)dbase[c] access, } 1 14 return N0T_F0UND, 160 } 161 return NOT FOUND, 1 1 5 } 1 16 162 1 1 7 uchar dbWrιteAccess(servStruct* s, uchar access){ 1 18 / ********* * ** * * * ** * ***** * **** ** ********* ** ** * ** / LISTING dbas 1 19 uint c, 1 uchar dbAdd(servStruct* s), 120 bit foundFlag, 1 21 2 uchar dbDel(servStruct* s) 122 3 uchar dbWrιteAccess(servStruct* s, uchar access), //Check to see if this entry is present uchar dbReadAccess(servStruct* s), 123 foundFlag=0, 4 124 5 uchar dbSearchServιce(uchar start, servStruct* s), for(c-0,c<totalEntrιes,c++){ 125 6 uchar dbSearchAddress(uchar start servStruct* s), ιf(dbase[c] dbs service—s >servιce){ 126 7 ιf(dbase[c] dbs addr node—s->addr node){ 127 8 #defιne NOT_FOUND OxFF ιf(dbase[c] dbs addr script—s->addr scrιpt){ 9 #defιne MAX_DB_ENTRIES 64 Appendix Appendix 18 typedef struct) 19 #prαgmα NOINIT servStruct dbs; 20 uchαr PrnBuff[PRN_BUFF_SIZE]; uchar access; 21 øprαgmα INIT IdbEntry; 22 uchαr • PrnWrtPtr; 23 uchαr * PrnRdPtr; extern dbEntry dbase[MAX_DB_ENTRIES]; 24 uchαr line; extern uchar totalEntries; 25 bit PrnWrαp; 26 LISTING ioregs.h 27 enum{GET_CMD , PRN-ST , EXIT , END-OF_CMDS} ; ******************* / 28 29 //void tιmer6() interrupt TIMER6 using displαyRegs{ /* Xilinx Registers*/ ******************* / 30 void tιmer6() interrupt TIMER6 { 31 /******♦♦********♦******•**•**/ #defιπe LOCI near 32 / ♦ #defιne LOC2 far 33 This thread is launced by the print routine and runs extern ulaw LOCI CodecReg; 34 for the duration of printing the text string. The extern uint L0C2 DtmfReg; 35 routine then disables itself. extern uint LOC1 CidReg; 36 //extern uint LOC2 OH_RιngReg; 37 Interrupt time is 100us. extern uint LOC2 PnntReg; 38 •/ extern uint LOCI StatusReg; 39 static uchar col; extern uint LOCI SelfAddrReg; 40 static bit clearEOL; extern volatile uint LOC2 VFOReg; 41 extern volatile uint LOC2 VFIReg; 42 T6 ■= TIMER6_REL0AD; extern uint LOCI odeReg; 43 ιf(clearE0L==0){ extern uint LOCI TxReg.RxReg; 44 if(PrnWrtPtr I- PrnRdPtr){ 45 ιf((VF0Reg&0x80)~0){ //Check busy flag. LISTING display.c 46 ιf(*PrnRdPtr—'\n'){ 47 clearEOL-l; #include "defs.h" 48 } #ιnclude <regl61.h> 49 else. #include <intrpdef.h> 50 VFlReg=*PrnRdPtr; ^include "globals. h" 51 col++; #include "ioregs.h" 52 } #include "prior. h" 53 PrnRdPtr++; #include "display. h" 54 ιf(PrnRdPtr>-(PrnBuff+PRN_BUFF_SIZE)){ 55 PrnRdPtr-PrnBuff; #defιne TIMER6_REL0AD 1000 56 PrnWrap.0; 57 } ifdef PHYTEC 58 } #define PRN_BUFF_SIZE 40 59 } #else 60 } ødefine PRN_BUFF_SIZE 80 61 else. #endιf 62 i f (col <DISPLAY JYIDTH) { 63 VFlReg=' '; #defιne DISPLAY_WIDTH 20 64 col++; Appendix Appendix } 112 else{ 113 wrtCmd(0x3c), lιne++; 114 wrtCmd(0x06), ιf(lιne>3){ 115 //wrtC d(øxøF), //Cursor ON lιne-0; 116 wrtCmd(øxøC); //Cursor OFF } 117 wrtCmd(0xl4); moveEL(lιne.ø); 118 wrtCmd(øxøl), col=0; 119 delαy(løøøø), cleαrEOL-0; 120 } } 121 122 d moveEL(uchαr row, uchαr col){ 123 /** * ***** * ****** * **** *** *** * *** * * / 124 //RS low in thsi mode #defιne delαy(dly) for(ι-0;κdly;ι++) 125 lιne=row, 126 swιtch(row){ void wrtCmd(uchαr cmd){ 127 case 0 /• ***************** '/ 128 /•---*/ int i , 129 wr«md(øx80+col); 130 break, VFøReg = ond, 131 1=100; 132 case 1 while(VF0Reg&0x80){ 133 /•---•/ ιf(-ι==.0){ 134 wrtCmd(0xC0+col), breαk; 135 break, } 136 } 137 case 2 } 138 /•---•/ 139 wrtCmd(0x94+col); votd vfdlnιt(){ 140 break, /****♦*♦*****♦/ 141 uint i; 142 case 3 143 /•-- •/ T6C0N = C0UNT_DOWNISTD_TIMER_MODEIPRESCALE_16; 144 wrtCmd(0xD4+col); T6IC - INT_ENABLEIT6_ILvLIT6_GLVL; 145 break, T6 = TIMER6..REL0AD; 146 T6R = 1; 147 default 148 /•- -•/ PrnWrtPtr=PrnRdPtr-PrnBuff; 149 #ιf TEST ι= 0 150 whιle(l), // ModeReg-1; //Select LCD 151 #endιf 152 return, VFøReg.0x38; 153 } delαy(4000) ; 154 } VF0Reg-0x38; 155 delαy(løø); 156 d putsEL(uchar * text){ VF0Reg-0x 3 8, 157 /***********************/ delαy(100); 158 uchar* p, Appendix Appendix 159 206 1 60 p-text, 207 161 whιle(*p){ 162 ♦ PrnWrtPtr++ - *p, LISTING t 163 i f (PrnWrtPtr >« (PrnBuff +PRN_BUFF_SIZE)){ 164 PrnWrtPtr - PrnBuff, void mainOI 1 65 PrnWrαp-1, int i, 1 66 } ι = 5 167 p++, I 1 68 } 169 //Add EOL LISTING uart 170 •PrnWrtPtr++-'\n" , 1 71 if (PrnWrtPtr >- (PrnBuff +PRN_BUFF_SIZE)){ 1 #ιnclude defs h 1 2 PrnWrtPtr - PrnBuff , 2 #lf DEBUG-.0UT—UART 1 73 PrnWrαp=l, 3 #ιnclude <regl61 h> 174 } 4 #ιnclude <ιntrpdef h> 175 } 5 tfmclude <ιntrιns h> 1 6 6 #ιnclude globals h 1 77 void putsLenEL(uchαr * text, uchαr len){ 7 tfinclude prior h 178 /************************************ / 8 #ιnclude uart h 179 uchαr * p, 9 #ιnclude strutils h 180 uint i , 10 181 ιf(len >« DISPLAY_WIDTH){ 11 #ιfdef PHYTEC 182 return, 12 #defme UART_BUFF_SIZE 120 183 } 13 #else 184 14 #defιne UART_BUFF_SIZE 240 185 1=0, 15 #endιf 186 16 187 p-text , 17 #defιne MAX MSG_LEN 60 188 18 189 κhιle(*p){ 19 static bit TxActiveFlag, 190 *PrnWrtPtr++ - *p, 20 191 if (PrnWrtPtr >- (PrnBuf +PRN_BUFF_SIZE)){ 21 #pragma NOINIT 192 PrnWrtPtr - PrnBuff , 22 uint UartTimer, 193 PrnWrαp-1, 23 static uchar near uartBuff[UART_BUFE_SIZE], 194 } 24 static uchar near * uartWrtPtr, 195 P++. 25 static uchar near * uartRdPtr, 196 ιf(ι++ >- len){ 26 197 break, 27 sbit TxPin =. P 3 ^10, 198 } 28 sbit TxDir - DP3 Λ 10, 199 } 29 sbit RxPin - P3 Λ 11, 200 30 sbit RxDir - DP3 Λ 11, .01 //Add EOL 31 #defιne INPUT 0 -02 *PrnWrtPtr++-'\n' , 32 #defιne OUTPUT 1 203 if (PrnWrtPtr >- (PrnBuff +PRN_BUFF_SIZE)){ 33 204 PrnWrtPtr - PrnBuff, 34 void uartlnιt(){ 205 PrnWrap-1, 35 /*****»**•♦*****/ Appendix Appendix S0CON - BAUDGEN.O I LOOPBACICOFF IOVERRUN_ONIFRAMING_ONIPARITY_OFF I\ 83 #endιf RX_ENAB_ONIONE_STO I BIT8.DATA; 84 85 void putsUart(uchar* text) . //38K baud rate. 86 ************** * **** * * * **/ S0BG - 12; 87 //Ensure there is enough in the way of room for S0BRS- 0; 88 //MAX.MSG-.LEN chars . 89 if(uartWrtPtr > (uartBuff+UART_BUFF_SIZE-MAX_MSG_LEN)){ TxDir-OUTPUT; 90 //Leave behind the zero Move to start of buffer. TxPιn-1; 91 uartWrtPtr=uartBuff; RxDir-INPUT; 92 } S0TIC- INT_ENABLE IS0T-.ILVL IS0T_GLVL; 93 94 //OK now free and clear to just write data #ιfdef NEED-RX 95 #ιfdef TIMESTAMP S0RIC- INT.ENABLE I S0R_ILVL I S0R_GLVL ; 96 uartWrtPtr =- formatDecUιnt(uartWrtPtr,UartTιmer); #endιf 97 //Add space 98 *uartWrtPtr++ = ' ' ; //Init pointers 99 fϋendif uartWrtPtr - uartRdPtr - uartBuff; 100 uartWrtPtr=strCpy(uartWrtPtr,text); 101 } 102 103 void putsUart2(uchar* textl, uchar* text2){ void ascTx() interrupt ASC0TX{ 104 /****** * ******* * **** * *********** ** ** ** ** * */ /*****************************/ 105 //Ensure there is enough in the way of room for ιf(uartWrtPtr !- uartRdPtr){ 106 //MAX_MSG_LEN chars TxActιveFlag»l; 107 if(uartWrtPtr > (uartBuff+UART_BUFF_SIZE-MAX_MSG_LEN)){ ιf(*uartRdPtr){ 108 //Move to start of buffer SøTBUF-'uartRdPtr; 109 uartWrtPtr=uartBuff; uartRdPtr++; 1 10 } } 1 1 1 //OK now free and clear to just write data. else{ 1 1 2 #ιfdef TIME.STAMP //if encounter a zero then wrap to start 1 13 uartWrtPtr-formatDecUιnt(uartWrtPtr,UartTιmer); uartRdPtr-uartBuff; 1 14 //Add space //Need to re-envoke the tickleO fnct. as 1 1 5 *uartWrtPtr++ = ' ', //we have used this interrupt. 1 16 #endιf TxActιveFlag=ø, 1 1 7 uartWrtPtr=strCpy(uartWrtPtr, extl); } 1 18 uartWrtPtr=strCpy(uartWrtPtr,text2); } 1 1 9 } else{ 1 20 TxActιveFlag«0; 121 } 122 void tιckleUart(){ } 123 124 ιf(TxAct veFlag=»ø){ #ιfdef NEED.RX 1 25 i f (uartWrtPtr I- uartRdPtr){ void ascRx() interrupt ASC0RX{ 126 //Post an interrupt to get process started. /*********************** ** * * */ 1 27 S0TIR=1 ; 128 } } 1 29 } Appendix Appendix 130 } 42 mai lAddr toAddr , /' For RPs & EXCEPTIONS 131 43 uchar payType, /• <PAYTYPE> 132 øendif 44 uchar payLen , /* <PAYLEN> 45 umon{ LISTING globals h 46 uchar* payPtr, /* for <PAYLEN> > 1 47 uchar payData, /* for <PAYLEN> .. 1 1 #defιne uchαr unsigned char 48 }up, 2 #defιne uint unsigned mt 49 }ιmfStruct , 3 #defιne ulong unsigned long 50 4 #defιne ulaw unsigned char 51 typedef struct{ 5 52 uchar active, /* App Specific */ 6 /* Type used by all dispatchers in accessing scripts */ 53 uchar msgType, 7 typedef uchar (*scπptPtr)(uchar* msg, void* ssPtr), 54 uchar node, /* Src Address */ 8 typedef void (*phStatePtr)(), 55 uchar script, /* Src Address */ 9 56 }remoteState, 10 typedef struct. 57 11 uchar node, 58 12 uchar script, 59 typedef structf 13 }address, 60 ulaw xhuge* trkPtr, 14 61 uchar state, 15 typedef struct{ 62 }playStruct, 16 uchar service, 63 #defme PLAY_IDLE 0 17 address addr, 64 #defιne PLAY_INIT 1 18 }servStruct, 65 defme PLAY_ACTIVE 2 19 66 #defιne PLAY CLOSE 3 20 typedef struct. 67 21 address addr, 68 typedef struct{ 22 //uint ackTimer, 69 uchar active, 23 JmailAddr, 70 uchar digit, 24 71 }dtmfStruct, 25 typedef struct{ 72 26 ailAddr* mailList, 73 /* Vars*/ 27 uchar eol, /• End of List Index 74 extern uchar SelfAddr, 28 uchar mailListSize, 75 29 }maιlStruct, 76 30 77 Commentary on the I fStruct 31 /»***************#****»**•* ********************** ^ 78 32 /• Internal Message Format structure definition */ 79 33 /************•*•*♦****»*•** *******♦*************•/ 80 The ImfStruct is the means employed for connecting the 1/0 of the 34 typedef struct { 81 scripts to the bus Because of the ER model the non-stream scripts 35 scπptPtr script, /* Address of the owning script 82 can use a single ImfStruct per script Many of the fields will be 36 address fm, /* From script address 83 modified continually as the ImfStruct is used for a multiplicity of 37 uchar sgType; /* Used in both directions 84 differnet messages types, ie an incoming RP_SPAWN can cause an 38 uchar rpStarted 1, /• Rx ' d message that RP started 85 PR-STARTED, RP_ENDED or EXCEPTION - so here is oine example where 4 39 uchar rpEnded 1, /* Rx'd message that RP ended 86 differnet message types pass thro' the same imfStruct 40 uchar rpError-1; /• Rx' d message RP ret error 87 41 mailStruct* mailPtr; /• For DATA_EVENTS, STREAMS 88 For this reason a boot initialisation of these scripts is pointless Appendix Appendix 89 90 91 92 93 94 95 96 97 98 99 100 101 102 he 1 2 3 4 5 6 7 8 9 10 #ιf DEBUG_OUT==UART 57 //If safe to write then do so 11 #ιnclude uart h 58 NιcTxQueue[TxQuWrtIndex]-ιmfPtr, 12 #ιnclude strutils h 59 TxQuWrtIndex++, 13 #endιf 60 ιf(TxQuWrtIndex>=TX_QUEUE_SIZE){ 14 61 TxQuWrtIndex=ø, 15 #ιfdef PHONE 62 TxQuWrapFlag=l, 16 #ιnclude zones h 63 17 } #ιπclude phone\ph-maιn h 64 //IEN 1 , 18 #endιf 65 19 } 66 20 #defιne TX_QUEUE_SIZE 8 67 void mcTxDispO . 21 #defιne TX.TIMEOUT 200 68 /* ****************/ 22 69 uchar cs, 23 //Control of extention calls 70 uint i , j .msgType, added, 24 bit PπvateFlag, 71 //uint notAdded, 25 uchar PπvateNode, 72 uint payLen.payLoc, 26 73 mailAddr* maPtr, 27 uchar near NicTxBuff[MAX_PKT_SIZE], 74 imfStruct* i fPtr, 28 uchar TxTimer, 75 uint energy, 29 static imfStruct* NιcTxQueue[TX_QUEUE_SIZE], 30 76 #ιf DEBUG_OUT-=UART static uchar TxQuRdlndex, 77 uchar str[4] , Appendix Appendix 78 #endιf 125 #endιf 79 126 80 //constant is mag per bit threshold. 127 case EXCEPTION- 81 #defme THRESHOLD 0*SPCH_PKT_SIZE 128 /* */ 82 129 case RP.STARTED. 83 //Check to see if TX is busy or "jammed", 130 /* • / 84 i f (TxPendi ngFlag){ 131 case RP_SPAWN 85 ιf(TxTιmer— 0){ 132 / . » / 86 //Resend the sg 133 case DATA_ACK: 87 goto LblSendMsg; 134 / » . / 88 } 135 NιcTxBuff[ι++] - imfPtr->toAddr.addr.node; 89 return, 136 NιcTxBuff[ι++] - ιmfPtr->toAddr addr script; 90 } 137 NιcTxBuff[TOADDRLEN_INDEX] = 2; /* <T0ADDR> length info */ 91 138 break, 92 ιf((TxQuWrapFlag—0)&8,(TxQuRdIndex—TxQuWrtIndex)){ 139 93 return; 140 case DATA.EVENT 94 } 141 /* •/ 95 142 maPtr = ιmfPtr->maιlPtr->maιlLιst; 96 ιmfPtr=NιcTxQueue[TxQuRdIndex] ; 143 97 TxQuRdIndex++; 144 //notAdded=0, 98 l f(TxQuRdIndex>-TX_QUEUE_SIZE){ 145 added=0, 99 TxQuRdIndex-0; 146 100 TxQuWrapFlag-0, 147 /* Fill out the <ToAddr> list */ 101 } 148 for( «0,j<imfPtr->mailPtr->eol;j+- { 102 149 ιf((((maPtr+j)->addr.scrιpt)&øx8ø)-=ø){ 103 #defιne TOADDRLEN.INDEX 1 150 /* If the DE_ACK bit is clr'd then add */ 104 #defιne TOADDR_INDEX 2 151 /• address to list */ 105 l«TOADDR_INDEX; 152 NιcTxBuff[ι++] - (maPtr+ )->addr node; 106 153 NιcTxBuff[ι++] - (maPtr+j)->addr.script; 107 msgType=ιmfPtr->msgType; 154 (maPtr+ )->addr script I- 0x80; /* Set the SCK- . FLAG */ 108 155 added++, 109 /***************************/ 156 } 110 /• 1 The <T0ADDR> listing */ /********* 157 //else{ 111 ******************/ 158 // notAdded++; 112 swιtch(msgType){ 159 //} 113 case BROADCAST: 160 } 114 /* V 161 115 NιcTxBuff[TOADDRLEN_INDEX] - 0; 162 i f (added— 0){ 116 break, 163 //ensure this ob doesn't get processed again 117 164 //imf Ptr->pendι ng=0 ; 118 case RP..ENDED: 165 //and exit 119 /* •/ 166 return, 120 #lf DEBUG-.0UT— UART 167 } 121 f ormatDecUchar(str , imf tr->toAddr . addr . node) , 168 122 putsUart2("Sendιng RPE fm node: ",str); 169 #ιfdef MORE_SOPHISTICATED 123 formatDecUchar(str,ιmfPtr->toAddr addr script); 170 ιf(notAdded > 0){ 124 putsUart2("scrιpt ",str); 171 notify someone Appendix Appendix 172 } 219 /• Then the script # •/ 173 #endιf 220 NicTxBuff [ι++] « ιmfPtr-5-fm script; 174 221 175 /• Add back in the <T0ADDR> length •/ 222 176 NlcTxBuff[TOADDRLEN_INDEX] - ι-2; 223 /• 3 The MsgType •/ 177 break, 224 /**************** * */ 178 225 NicTxBuff[ι++] - msgType, 179 case STREAM 226 180 /* */ 227 /*** ** **** *************** */ 181 //This differs from the expansion of the data event 228 /• 4 The <PAY_TYPE_LEN> •/ 182 //mailing list as no check on an ack is required 229 /**»***♦*»♦**♦**«**♦**♦»**/ 183 #ιfdef PHONE 230 NicTxBuff[ι++] - imfPtr-ypayType; 184 ιf(PrιvateFlog){ 231 payLoc=ι , //Used for zero energy streams 185 NιcTxBuff[TOADDRLEN_INDEX] - 2; 232 payLen = NιcTxBuff[ι++] ■= ιmfPtr->payLen, 186 NιcTxBuff[ι++] - PrivateNode; 233 187 NιcTxBuff[ι++] - LC_PH_SPCHSINK, 234 /**** ****** * *********/ 188 } 235 /* 5 The <PAYL0AD> */ 189 else{ 236 /** * ** * **** * * * ****** * 190 #endιf 237 swιtch(payLen){ 191 maPtr - ιmfPtr->maιlPtr->maιlLιst, 238 case 0 192 239 /•- -*/ 193 /* Fill out the <ToAddr> list */ 240 break, 194 for(j=0;j<ιmfPtr->maιlPtr->eol;j++){ 241 195 NicTxBuff[ι++] - (maPtr+j)->addr node; 242 case 1 196 NicTxBuff[ι++] » (maPtr+ )->addr script, 243 /•---•/ 197 } 244 NιcTxBuff[ι++] - ιmfPtr->up payData; 198 245 break, 199 /* Add back in the <T0ADDR> length ♦ / 246 200 NιcTxBuff[TOADDRLEN_INDEX] - 1-2, 247 default 201 #ιfdef PHONE 248 / ♦ -- •/ 202 } 249 if(msgType—STREAM){ 203 #endιf 250 energy=0, 204 break, 251 for(j=0; <payLen,j++){ 205 252 NicTxBuff[I] - *(ιmfPtr->up payPtr+ ); 206 #ιf TEST I. ø 253 energy +. -(NicTxBuff[ι]) & 0x7F, 207 default: 254 ι++, 208 /* •/ 255 } 209 whιle(l); 256 210 #endιf 257 if(energy < THRESHOLD){ 211 } 258 NicTxBuff[payLoc]=0; 212 259 ι=payLoc+l, 213 /♦****♦**♦*•»»*•***♦/ 260 } 214 /* 2. The <FMADDR> */ 261 } 215 /•♦****•**••**♦****#/ 262 else{ 216 /• Add in the SelfAddr •/ 263 for(j=0, <payLen,j++){ 217 NιcTxBuff[ι++] = SelfAddr, 264 NιcTxBuff[ι++] - *(ιmfPtr->up payPtr+j), 218 265 } Appendix Appendix Appendix Appendix //pαrent(src) it is assigned outside of the "Scripts" array 12 /* Handy Enums of Process States */ #defιπe LC_PH_SPCHSINK øxF 13 #defιne IMF-IDLE 0x0 14 #define RP_STARTED_CLEAR 0x0 LISTING nicrx h 1 5 #defme RP_STARTED_SET 0x1 1 6 #deftne RP.ENDED.CLEAR 0x0 /* */ 17 #defιne RP_ENDED_SET øxl /* Function Prototypes */ 18 • / 19 /* Payload Types */ void nicRxlnitt); 20 #defιne VOID 0x00 uchar addrCmp(maιlAddr * mal address* ma2); 21 #defιne UNSIGNED_CHAR 0x01 uchar process aιl(uchar action, address a, imfStruct * imfPtr), 22 #defme SIGNED_CHAR 0x02 uchar ρrocess aιlAck(uchar* f Ptr, mailStruct* msPtr); 23 #defme UNSIGNED-INT 0x03 void sι_SpchSιnk(uchar* msg); 24 #defιne SIGNED-INT 0x04 25 #defιne STRING 0x05 / * * * * * * * * * * * * * * * 26 #defιne ALAW_ENCODED 0x06 /* Global Vars */ 27 #defιne ULAW_ENCODED 0x07 / * * * * * * * * * * * * * * * / 28 #defme WAVE-COMPRESSED 0x08 extern int SpchSιπkBuff[3][SPCH_PKT_SIZE]; 29 #defιπe ASCII 0x10 extern uchar near SinkBufflndex; 30 #defιne NODE_ADDRESS 0x11 extern uchar near Here[3], 31 #defιπe SERVICE_ENUM 0x12 extern uint CwdTimer, 32 33 /* DTMF defines */ #defιne RE OVE_FROM_MAIL_LIST 0 34 #defme DTMF_M0DE #defιne ADD_TO_MAIL_LIST 1 35 #defιπe PULSE_MODE #defιne CODEC-. WATCFLDOG-JI EOUT 1000 36 37 /• Function IDs */ 38 (Hdefine STD_PSN #ιf TEST O 39 #defιne STD_PHN extern uchar near RxBuffA[]; 40 #defme COMPUTER extern uchar near RxBuffB[]; 41 #defιne PRINTER #endιf 42 43 /• Service IDs */ 44 #defιne SPCH_SERVICE 45 #defme RING-SERVICE LISTING defs h 46 #defιne CID.SERVICE 47 /* Msg Types */ 48 //#defιne MAX-SPCH-XHANNELS #defιne STREAM 0x80 49 #defme SPCH_FLOW_0FF #defme DATA_EVENT 0x40 50 #defme SPCH_FL0W_0N #defme DATA_ACK 0x20 51 ϋfdefine RP.SPAWN 0x10 52 tfdefine SPCH_PKT_SIZE 3 2 #defme RP_STARTED 0x08 53 #defιne RP_ENDED 0x04 54 #defme MIN ^ PKT_SIZE 10 #defιne EXCEPTION 0x02 55 #defme MAX_PKT_SIZE SPCH_PKT_SIZE+18 #defme BROADCAST 0x01 56 #defιne V0ID-.MSG 0x00 57 #ιfdef PHYTEC 58 #defιne SPCH_MAIL_LIST_SIZE 6 Appendix Appendix ♦define RING_MAIL_LIST_SIZE 6 1 1 ♦include ulaw h' ♦define CID_MAIL_LIST_SIZE 6 12 ♦include 'codec h ♦else 13 ♦include spch h" ♦define SPCH_MAIL_LIST_SIZE 16 14 ♦include prior h ♦define RING_MAIL-.LIST-.SIZE 16 15 ♦define CID_MAIL_LIST_SIZE 16 16 ♦ifdef PSN #endιf 17 ♦include psn\lc_maιn h" /* 18 ♦include psn\lc_scrpt h" Breakout of max pkt size is thus: 19 ♦include ' psn\lc_tιmer h" <msg LenxmsgTypextoAddrLenxtoSOxtoSc π pt> <fmS0xfm scrι txpayLoad> 20 //"iDebug 1 1 1 12 1 1 64 21 ♦include psn\lc_pιns h 22 ♦endif ie above li st accomodates 6 <toAddr>, overall length is 81 23 •/ 24 ♦ifdef PHONE 25 ♦include "phone\ph_maιn.h" //Enu of the means of conecting thro' to codec 26 ♦include ' phone\ph_scrpt h" ♦define STD-.CALL 0 27 ♦include phone\ph_tιmer h" ♦define GEN.DTMF 1 28 //n iDebug ♦define PLAY-TRACK 2 29 ♦include phone\ph_pιns h" ♦define REGEN-CID 3 30 ♦endif 31 //Enum of test states 32 ♦define SW_TEST 0x1 33 void tιmer 3 Inιt(){ ♦define HW_TEST 0x2 34 /***************/ 35 //Set up for 10ms interrupts //Enum of debug outputs 36 //Timer is clk'd at 1MHz ♦define LCD_DISPLAY øxl 37 T3C0N - C0UNT_D0WNISTD_TIMER_M0DEIPRESCALE_16; ♦define UART 0x2 38 T3 = TIMER3_REL0AD; 39 T3IC = INT_ENABLEIT3_ILVLIT3_GLVL; //Misc enums 40 T3R = 0, ♦define RING-.TIME0UT 1000 41 ♦define RESEND-.LIMIT 3 42 ♦define STAR_KEY øxB 43 sbit normalPιn»P3 Λ 4, ♦define POUND.KEY 0xC 44 sbit nullPιn=P3 Λ 5, 45 LISTING spch c 46 void spchEncodeO interrupt TIMER3 using encRegs{ 47 /************************************** *** am/ ♦include <regl61.h> 48 //04/13/98 0640 pm Measured exec time of 300us ♦include • ntrpdef h> 49 ulaw* toPtr, ♦include •cintπns h> 50 uint i, ♦include "defs h" 51 ♦include "globals h" 52 //""DEBUG ♦include "loregs h" 53 //♦ifdef PHONE ♦include "nictx h" 54 //Test2Pιn=l, ♦include "nicrx.h" 55 //♦endif ♦include "zones h" 56 ♦include ' dbase h ' 57 T3R= //Subsequently trig by codec blk xfr Appendix Appendix T3 - TIMER3_REL0AD; 105 /* */ 106 //Output re-constituted CID data //Advance the SpchSinklndex so that respective 107 //geπCidO, //buffer's contents are static for the encode 108 ♦endif //process. 109 swιtch(CodecTxControl). 110 case STD_CALL: 111 } /* */ 112 //Run an encode - currently ulaw 113 void encodeSpch(){ 114 / * * ***** ** ****** * ιf(Here[SιnkBuffIndex]'-0){ 115 //ulaw encode the summed speech inputs //DEBUG 116 int* fmPtr, normalPιn-1, 117 int* limit, 118 ulaw* toPtr; Here[SinkBuffIndexj 0; //Init for the next time use 119 int ImValue, SιnkBuffIndex++; 120 ιf(SιnkBuffIndex>2){ 121 //Compute the toPtr SιnkBuffIndex=0; 122 toPtr =• PecøFlag'CodecTxBuffA CodecTxBuffB, } 123 encodeSpchO, 124 //Compute the fmPtr - remember SinkBufflndex } 125 //is one advanced from the data buffer of interest else{ 126 swιtch(SιnkBuffIndex){ //DEBUG 127 case 0 nullPin.l, 128 / ♦ - •/ 129 fmPtr-_SpchSιnkBuff[2][0]; toPtr -. Pec0Flag?CodecTxBuf A CodecTxBuffB, 130 I i i t=SSpchSιnkBuf f [2] [ø]+SPCH_PKT_SIZE , for(i-0,i<SPCH_PKT_SIZE,i++){ 131 break, •toPtr-øxFF, 132 toPtr++, 133 case 1 } 134 /*-- •/ } 135 fmPtr=SSpchSιnkBuff [0][0] ; nullPm-0, 136 I i mi t-&SpchSι nkBuf f [0] [0]+SPCH_PKT_SIZE ; normalPιn-0, 137 break, break; 138 139 case 2 case GEN.DTMF: 140 /*-- */ / ♦ */ 141 fmPtr=8,SpchSιnkBuff [1][0] ; dtmfGeπO, 142 lιmιt=&SpchSιnkBuff[l][0]+SPCH_PKT_SIZE; break, 143 break, 144 ♦ifdef PHONE 145 default case PLAY-TRACK 146 /•-- •/ / . . / 147 fmPtr-SSpchSinkBuff r2][0] ; replayTrack(), 148 lιmιt=&SpchSιnkBuff[2][0]+SPCH_PKT_SIZE, break, 149 break, 150 //case REGEN_CID- 151 Appendix Appendix //Perform linear to ulaw conversion. 199 0X0C00, 0X0BFF, 0X0BFC 0X0BF7, 0X0BF1, 0X0BE8 0X0BDE, 0X0BD2, whιle(fmPtr<lιmιt){ 200 0X0BC4, 0X0BB5, 0X0BA3 0X0B90, 0X0B7B, 0X0B64 0X0B4C, 0x0832, ιf(CodecSιnkFlag){ //03/31/98 09 54 am 201 0X0B16, 0X0AF8, 0X0AO9 0X0AB7, 0X0A95, 0X0A70 0X0A4A, 0X0A23, linValue-'fmPtr, 202 0X09FA, 0X09CF, 0X09A3 0x0975, 0x0946, 0x0916 0X08E4, 0X08B0, 203 0X087C, 0x0846, 0X080F 0x0706, 0X079C , 0x0761 0x0725, 0X06E8, ιf(lιnValue<0){ 204 0X06AA, 0X066B, 0X062B 0X05EA, 0X05A8, 0x0565 0x0521 , 0X04DC, lιnValue--lιnValue; 205 0x0497, 0x0451, 0X040A 0x0 3 C3, 0X037B , 0x0333 0X02EA, 0X02A1, ιf(lιnValue<βxldf0){ 206 0x0257, 0X020D, 0X01C2 0x0178, 0X012D, 0X00E1 0x0096, 0X004B, •toPtr=lιn2u[lιnValue] Λ 0x7F, 207 0x0000, 0xFFB5, 0xFF6A 0XFF1F, 0xFED3, 0xFE88 0xFE3E, 0XFDF3, } 208 0XFDA9, 0XFD5F, 0XFD16 øxFCCD, 0xFC85, 0xFC3D 0xFBF6, øxFBAF, else{ 209 0xFB69, 0xFB24, øxFADF 0xFA9B, 0xFA58, 0xFA16 0xF9D5, 0xF995, •toPtr-ø, 210 0xF956, 0xF918, 0XF8DB 0xF89F, 0xF864, 0xF82A 0xF7Fl, 0XF7BA, } 211 0XF784, 0xF750, 0xF71C 0XF6EA, 0xF6BA, 0xF68B 0xF65D, 0xF631, } 212 0XF606, 0xF5DD, 0xF5B6 0xF590, 0xF56B, 0xF549 0xF527, 0xF508, else . 213 0xF4EA, 0xF4CE, 0XF4B4 0xF49C, 0XF485, 0xF470 0XF45D, 0xF44B, ιf(lιnValue<0xldf0){ 214 0XF43C, 0xF42E, 0xF422 0XF418, 0XF40F, 0xF409 0xF404, 0xF401, •toPtr—lιnZu[lιnValue]; 215 0xF401, 0XF401, 0xF404 0xF409, 0XF40F, 0xF418 0xF422, 0XF42E, } 216 0xF43C, 0XF44B, 0xF45D 0xF470, 0XF485, 0XF49C 0XF4B4, 0xF4CE, else{ 217 0XF4EA, 0xF508, 0xF527 0xF549, 0xF56B, 0xF590 0XF5B6, 0XF5DD, *toPtr-øx80, 218 0XF606, 0xF631, 0xF65D 0xF68B, 0XF6BA, 0XF6EA 0XF71C, 0XF750, } 219 0XF784, 0xF7BA, 0XF7F1 0xF82A, 0xF864, 0xF89F 0xF8DB, 0xF918, } 220 0xF956, 0xF995 0XF9D5 0xFA16, 0xFA58, 0xFA9B øxFADF, 0XFB24, } 221 0xFB69, øxFBAF, 0XFBF6 0xFC3D, 0xFC85, øxFCCD 0xFD16, 0xFD5F, else. 222 0xFDA9, 0xFDF3, 0XFE3E 0xFE88, 0XFED3, 0XFF1F 0XFF6A, 0xFFB5 //Zero the buffers - 03/31/98 11.41 am 223 }, ♦ toPtr-øxFF, 224 •fmPtr-0, 225 } 226 ♦define tone697 0xl6d6; toPtr++, 227 ♦define tone770 0xl9 3 b, fmPtr++, 228 ♦define tone852 øxlbeb; 229 ♦define tone941 0xled5, } 230 ♦define tonel2090x279d, 231 ♦define tonel 33 60x2bc7, /**********************************/ 232 ♦define tonel4770x 3 065, /• Sine table with amp +/- 0X0C00 */ 233 ♦define tonel63 3 0χ 3 582, /* * * * *** * ******* * ** * *** ** * *** ****** / 234 //This table is generated with the utility found in CPROGS directory. 235 ♦define tone350 0x0b77, //This table has an amplitude of 00xC00, ie Oløbits 236 ♦define tone440 0x0e6a; const int sιne[256] " { 237 ♦define tone480 0x0fb9, 0X0000, 0X004B, 0x0096, 0X00E1, 0X012D, 0x0178, 0X01C2, 0X020D, 238 ♦define tone620 0x1450, 0x0257, 0X02A1, 0X02EA, 0x0333, 0X037B, 0X03C3, 0X040A, 0x0451, 239 0x0497, 0X04DC, 0x0521, 0x0565, 0X05A8, 0X05EA, 0X062B , 0X066B, 240 0X06AA, 0X06E8, 0x0725, 0x0761, 0X079C, 0X07D6, 0X080F, 0x0846, 241 void dtmfGen(){ 0X087C, 0X08B0, 0X08E4, 0x0916, 0x0946, 0x0975, 0X09A3, 0X09CF, 242 /*************/ 0X09FA, 0X0A23, 0X0A4A, 0X0A70, 0X0A95, 0X0AB7, 0X0AD9, 0X0AF8, 243 //DialTone: 350Hz + 440Hz 0X0B16, 0X0B32, 0X0B4C, 0X0B64, 0X0B7B, 0X0B90, 0X0BA3, 0X0BB5, 244 //Busy: 480Hz + 620Hz (50 50 On/Off) 0X0BC4, 0X0BDZ, 0X0BDE, 0X0BE8, 0X0BF1, 0X0BF7, 0X0BFC, 0X0BFF, 245 //RingBack 440Hz + 480Hz (2secs ON, 4 sees OFF) Appendix Appendix 246 293 ptr=CodecTxBuffB; 247 static unιon{ 294 1 imi t=CodecTxBuf fB+SPCH_PKT_SIZE ; 248 unsigned int l ; 295 } 249 uchar c[2_; 296 else . 250 }rowInteg J 297 //Pec0Flag==l . DMA from BuffB , Write BuffA 251 298 ptr=CodecTxBuffA; 252 static unιon{ 299 1 imi t=CodecTxBuf f A+SPCH_PKT_SIZE ; 253 unsigned int i; 300 } 254 uchar c[2]; 301 255 }colInteg , 302 //Copy the next block 256 303 whιle(ptr<lιmιt){ 257 unsigned int rowlnc, collnc; 304 dtmfSmpl - sιne[rowInteg c[l]] + sιne[colInteg c[l]] ; 258 int dtmfSmpl; 305 dtmfSmpl >>= 2; //Volume control . 259 ulaw* ptr 306 *ptr = ImToU(dtmfSmpl); 260 ulaw* limit, 307 ptr++; 261 308 rowlnteg.1+=rowInc; 262 swιtch(DtmfDιgιt){ 309 collnteg ι+=colInc; 263 case '0' : rowlnc - tone941 collnc 310 264 } case '1' : rowlnc - tone697 collnc 31 1 265 case '2' : rowlnc - tone697 collnc 31 2 266 case '3' : rowlnc =■ tone697 collnc 31 3 ♦ifdef PHONE 267 case '4' : rowlnc » tone770 collnc 314 void replayTrack(){ 268 case '5' : rowlnc - tone770 collnc 31 5 /*************** 269 case '6' : rowlnc - tone770 collnc 316 /* Playing Of Recorded Speech Tracks 270 case '7' : rowlnc - tone852 collnc 317 271 case '8' : rowlnc - tone852 collnc 318 This code looks for the Play startFlag to be set. If 272 case '9' : rowlnc 4. toπe852 collnc 319 it is then a switch is thrown, via CodecTxCoπtrol, and 273 case 'A' : rowlnc - tone697 collnc 320 blocks of the ulaw encoded tracks are then alternately 274 case 'B' : rowlnc - tone?70 collnc 321 loaded into the SpchSinkBuffs until the track is complete 275 case 'O : rowlnc - tone852 collnc 322 At this point the codec source returns to being the 276 case 'D' : rowlnc « tone941 collnc 323 incoming speech packets from the HSB. 277 case '♦' : rowlnc - tone941 collnc 324 */ 278 case '•' : rowlnc - tone941 collnc 325 static umon{ 279 //Control tone pairs 326 unsigned long I; 280 case 'R' : rowlnc - tone440 collnc tone48ø; break; //RingBack 327 unsigned char c[4]; 281 case 'T' : rowlnc - tone350 collnc tone440; break; //DialTone 328 }playCount; 282 case 'U' • rowlnc = tone480 collnc tone620; break ; //Busy 329 static const ulaw xhuge* playPtr; 283 330 ulaw* ptr; 284 default: 331 ulaw* limit; 285 rowlnc . ø; 332 286 collnc - 0; 333 swιtch(Play.state){ 287 rowlnteg i-collnteg .1-0; 334 case PLAY.IDLE: 288 } 335 / » * / 289 //Using the MSB of the integs a 5 the lo 336 break; 290 //into sine table. 337 291 ιf(Pec0Flag—0){ 338 case PLAY_INIT: 292 //Pec0Flag=>0 . DMA from BjffA, Wr 339 /* */ Appendix Appendix LISTING nicrx IZE]; IZE]; 0x8 1NICRX-.Z0NE-.ID10x1 0x8 INICRX_Z0NE_IDI x4 ed only its interrupt logic. IT5-.GLVL ; Appendix Appendix Appendix Appendix 138 ♦define PAYSTART *(msg+7) 185 139 186 l f (MSGTYPE— BROADCAST)!. 140 rxpιn-1; 1 87 //The BROADCAST message type is intercepted as its processing 141 1 88 //is unique 142 ιf(Pec6Flαg){ 189 143 msg=RxBuffB; 1 90 //Extract the node, script and service and add to the database. 144 } 191 ιf(T0SCRIPT !- 0){ 145 else{ 192 //Corrupt in some manner. 146 msg=RxBuffA; 193 goto LblUpdatelndex; 147 } 194 } 148 195 149 msgLen=*msg-l; 196 //Get the <PAYTYPE> 150 1 97 ιf(PAYTYPE !- SERVICE_ENUM){ 151 ♦ifdef CHECK_PKTS 1 98 //Corrupt in some manner. 152 totαlPkts++; 199 goto LblUpdatelndex; 153 ♦endif 200 } 154 201 155 //Check Status 202 payLen=PAYLEN; 156 if(*(msg+ιnsgLen+l)!-0){ 203 msg+-7; //move to start of payload; 157 goto LblPktError; 204 whιle(payLen){ 158 } 205 //Get the service 159 206 swιtch(s servιce=*msg++){ 160 //Compare checksums 207 case STD_PSN: 161 ιf(*(msg+msgLen) I- *(msg+msglen-l)){ 208 case STD_PHN- 162 //CS failure. 209 /• V 163 ♦ifdef CHECK_PKTS 210 s addr node - *msg++; 164 LblPktError: 21 1 s addr.script - *msg++; 165 /* V 212 dbAdd(Ss); 166 errPkts++; 213 break; 167 if(lastPktlnError). 214 168 conseqErrs++; 21 5 default. 169 } 216 /* •/ 170 lastPktlnError-l; 21 7 msg += 2; 171 ♦endif 218 } 172 return; 219 payLen — 3; 173 } 220 } 174 ♦ifdef CHECK.PKTS 221 goto LblUpdatelndex; 175 lastPktlnError-ø; 222 } 176 ♦endif 223 177 /• 224 ιf(TOSCRIPT == LC_PH_SPCHSINK){ 178 save the increment of the read pointer until the end 225 goto Lbll, 179 of the routine so that we can properly assess whether 226 } 180 an over-write occurred. 227 181 228 lff OSCRIPT >-, LC_TOTAL_SCRIPTS){ 182 229 //Just dump for the time being, 183 //! ! 'DEBUG 230 goto LblUpdatelndex; 184 //RxPιn-1; 231 } Appendix Appendix Appendix Appendix 420 / *****************************************/ 467 421 ιf(mαl->αddr node '- mα2->node){ 468 422 return 0, 469 //Jump directly to the payType 423 } 470 lf(PAYTYPE '= ULAW_ENCODED){ 424 471 return, 425 ιf(((mαl->αddr scrιpt)8.0x7f) I- ((mα2->scπpt)&0x7f)){ 472 } 426 return 0, 473 427 } 474 //DEBUG 428 return 1, 475 //pktpιn=l, 429 476 430 477 ♦ifdef PHONE 431 478 // Private Flag is set during the addition of a new party 432 * ** ********* *** ** * *** * ** * ** *** * * * * ** * ****** * **** ** ** **** **** * * ***** * * / 479 //to a conf call All other conversations are discarded at 433 /* Stream Receptor Scripts */ ****** ******************* 480 //this point 434 ********** ************************** *******/ 481 ιf(PrιvateFlag){ 435 int SpchSinkBuff[3] [SPCH_PKT_SIZE] , 482 ιf FMN0DE I - PπvateNode){ 436 uchar near SinkBufflndex, 483 //Discard all conversations but the intended one 437 uchar near Here[3] , 484 438 485 //DEBUG 439 void sι_SpchSιnk(uchar* msg){ 486 //pktpιn=0, 440 *********************** ******y 487 441 const uchar mask[]-{0xl,0x2,øχ ,0x8,0x10,øx20,øχ 0,0x80}, 488 return, 442 static char smpl, 489 } 443 int* ptr, 490 streamlndex=0, 444 int* limit, 491 } 445 int lin, 492 else{ 446 uint streamlndex, 493 ♦endif 447 bit foundFlag.firstPkt, 494 //Determine the streamlndex by looking up the 448 495 //fmAddr node in the mailing list of self 449 /* 496 foundFlag=0, 450 The byte here is bit addressable and is used 497 for(streamIndex-0,streamIndex<SpchMaιIStruct eol,streamIndex++){ 451 to determine if a particular source's packer has 498 ιf(spchMaιlLιst[streamIndex] addr node-FMNODE){ 452 arrived 499 foundFlag-1, 453 500 break, 454 This byte is used to steer arriving packets into 501 } 455 one of two free buffers whilst the third is being 502 } 456 encoded for ulaw output to the codec 503 ιf(foundFlag==0){ 457 504 return, 458 The buffers (A,B,C) are filled in a strict rotation 505 } 459 and passed on to the encode process after a fixed 506 ♦ifdef PHONE 460 time interval The var SinkBufflndex" is enumerated with 507 } 461 A,B,C to indicate which buffer will be passed on next 508 ♦endif 462 to the encode process Should 2 packets arrive from the 509 463 same source in a given window then the second 510 //05/0 /98 05 35 pm 464 packet is added into the free ' Buff+1 and the here 511 CwdTi er - C0DEC_WATCHJ30G_TIME0UT, 465 byte for that buffer has its approp bit set 512 466 •/ 513 //Determine the action for this msg Appendix Appendix 514 //action can be NOR4VIAL .OVERSPILL or TRASH 561 515 ιf((Here[SιnkBuffIndex] 8 mask[streamlndex])—0){ 562 case SPCH_PKT_SIZE 516 //Have not yet rx'd a pkt from this source in this window interval 563 /*-- */ 517 //so add in to the current buffer 564 //Point to the data 518 firstPkt - (Here[SinkBuffIndex]-=0) ? l 0, 565 msg+=7, 519 ptr-8,SpchSιnkBuff[SιnkBuffIndex][0]; 566 520 lιmιt-&SpchSιnkBuff[SιnkBuffIndex][0]+SPCH_PKT_SIZE, 567 //Now that the action and pointers have been 521 Here[SinkBufflndex] l= mask[streamlndex], 568 //determined process the msg 522 } 569 whιle(ptr<lιmιt){ 523 else. 570 smpl=*msg, 524 ιf(SιnkBuffIndex>=2){ 571 525 ιf((Here[ø] 8 mask[streamlndex])=-0){ 572 ιf(smpl 8, 0x80){ 526 firstPkt - (Here[0]~0)'l 0, 573 //Positive so just invert 527 ptr=&SpchSιnkBuff[0][0]; 574 smpl—smpl , 528 limit=&SpchSinkBuff[0][0]+SPCH_PKT_SIZE, 575 lin = u2Lιn[smpl]; 529 Here[0] l= mask[streamlndex], 576 } 530 } 577 else. 531 else{ 578 smpl Λ =0x7F, 532 goto LblOverFlow, 579 I in - -u2Lιn[smpl], 533 } 580 } 534 } 581 535 else{ 582 ιf(fιrstPkt){ 536 ιf((Here[SιnkBuffIndex+l] 84 mask[streamlndex])==0){ 583 •ptr - lin, 537 firstPkt - (Here[SmkBuffIndex+l]«ø)?l ø, 584 } 538 ptr-4SpchSιnkBuff[SιnkBuffIndex+l][0]; 585 else{ 539 Iimit=8,SpchSιnkBuff[SinkBuffIndex+1][0]+SPCH_PKT_SIZE , 586 •ptr +- lin, 540 Here[SιnkBuffIndex+l] I- mask[streamlndex] , 587 } 541 } 588 ptr++, 542 else{ 589 msg++, 543 goto LblOverFlow, 590 } 544 } 591 break, 545 } 592 546 } 593 default 547 594 /• •/ 548 //DEBUG 595 break, 549 596 } 550 swιtch(PAYLEN){ 597 551 case 0 598 LblOverFlow 552 /♦—-•/ 599 / . . / 553 //Only necessary to take action if first pkt 600 //pktpιn-0, 554 ιf(fιrstPkt) . 601 return, 555 whιle(ptr<lιmιt){ 602 556 •ptr - øxFF, 557 ptr++, 558 LISTING spch } 559 } /* Function Prototypes */ 560 break, void tιmer3lnιt() Appendix Page 57 void encodeSpchO, 35 void dtmfGenO; 36 caιc INT_ENABLE I EXT6_ILVL I EXT6_GLVL , void replayTrack(), 37 EXIC0NI =NEG«12, 38 //Allow jitter window of half the pkt duration 39 ♦define COUNT-0 0 #defιne TIMER3-.RELOAD (SPCH_PKT_SIZE/8)*300 40 PECC1 = INC_DST I BYTE_XFRICOUNT_0, //Rx Channel 41 SRCP1 = _sof_(&CodecReg); //Publish the sine table 42 DSTP1 = _sof_(SCodecRxBuffA); extern const int sιne[256], 43 44 PECC0 = INC-SRCIBYTE_XFRI COUNT_0; / Tx Channel 45 SRCP0 - _sof_(&CodecTxBuffA); LISTING codec c 46 DSTP0 > _sof_(δ.CodecReg) , 47 ♦include <regl61.h> 48 //Scπpts[LC_PH_SPCHPKT] script-(scnptPtr)so_SpchPkt; ♦include <ιntrιns.h> 49 Scrιpts[LC_PH_SPCHPKT] msgType-STREAM; ♦include <ιntrpdef h> 50 Sen pts [LC-.PH-.SPCHPKT] payType-ULAW_ENC0DED ; ♦include "globals h" 51 Scrιpts[LC_PH_SPCHPKT] payLen-SPCH_PKT_SIZE ; ♦include defs h" 52 Scrιpts[LC_PH_SPCHPKT] maιlPtr=&SpchMaιlStruct, ♦include "nictx h' 53 ♦include "nicrx h" 54 ♦include "loregs h" 55 bit CodecPostFlag; ♦include "codec. h" 56 void codecRx() interrupt EXT7 { //PEC1 ♦include ' prior h" 57 /**** . **** ... ** . * .**. ***** * *• • / ♦include ' zones h 58 //This interrupt is entered once the PECC has xfrd 59 //a complete block At this point this newly filled ♦ifdef PSN 60 //buffer needs to be transmitted on the HSB ♦include "psn/lc_scrpt.h" 61 static bit peclFlag, ♦include 'psn/lc_maιn h" 62 ιf(peclFlag==0){ ♦endif 63 peclFlag=l, 64 Scπpts[LC_PH_SPCHPKT] .up.payPtr=CodecRxBuffB; ♦ifdef PHONE 65 DSTPl-_sof_(&CodecRxBuffA) ; ♦include "phone/ph_scrpt h" 66 } ♦include "phone/ph_maιn h" 67 else{ //'! 'DEBUG 68 peclFlag=0, ♦include phone/ph_pιns h' 69 Sen pts [LC_PH_SPCHPKT] . up . payPtr-CodecRxBuf f A ; ♦endif 70 DSTPl=_sof_(&CodecRxBuffB); 71 } bit PecRefill.PecøFlag, FirstPkt; 72 ulaw CodecRxBuffA[SPCH_PKT_SIZE] ; 73 PECC1 SPCH_PKT_SIZE , ulaw CodecRxBuffB[SPCH_PKT_SIZE] ; 74 ulaw CodecTxBuffA[SPCH_PKT_SIZE] ; 75 ιf(CodecSrcFlag){ ulaw CodecTxBuffB[SPCH_PKT_SIZE] , 76 CodecPostFlag=l, 77 } void codecInιt(){ /*** * *** * *** * ***/ 78 } 79 CC15IC- INT-.ENABLEIEXT7_ILVL IEXT7.GLVL; 80 void codecTxQ interrupt EXT6{ //PEC0 EXIC0NI=NEG«1 ; 81 **************** ***** ** *** * **/ Appendix Appendix 82 LISTING psn/lc_scπpt 83 Experiments show that the loss of a complete packet 84 (64 samples) is barely audable. Therefore this routine 1 ******************* ****** 85 takes the simplistic approach to summing the various 2 /* Function Prototypes */ 86 speech channels of a conference call. It simply adds them 3 ************************* 87 into a common buffer as they arrive. Given a maximum 4 void IcScπptlnitO, 88 error in sampling rates of løøpp and a time to assemble 5 uchar chl_SpchFlow(uchar* msg, imfStruct* imfPtr); 89 a packet of 8ms this event will only happen 8E-3 * 1E4 or 6 uchar ch1_SpchMaιlLιst(uchar* msg, imfStruct* imfPtr); 90 once every 80 seconds - no problem. 7 uchar ch1_Rιng aιlLιst(uchar* msg, imfStruct* imfPtr); 91 */ 8 uchar ch1_CιdMaιlLιst(uchar* msg, imfStruct* imfPtr); 92 9 uchar chl_DιalDιgιtTιme(uchar* msg, imfStruct* imfPtr); 93 ιf(Pec0Flag—1){ 10 uchar ch1_DιalMode(uchar* msg, imfStruct* imfPtr); 94 Pec0Flag=0; 11 uchar ch2_DιalStr(uchar* msg, imfStruct* imfPtr); 95 SRCP0 - _sof_(CodecTxBuffA); 12 uchar chl_LιneSeιze(uchar* msg, imfStruct* imfPtr); 96 } 13 void loc_LιneSeιze(uchar action); 97 else{ 14 void de_CιdPkt(), 98 PecøFlag.l; 15 void de_RιngDet(), 99 SRCP0 = _sof.(CodecTxBuffB); 16 100 } 17 /* Global Vars */ 101 PECC0 1= SPCH_PKT_SIZE ; 18 extern uint CidTimer; 102 19 103 T 3 R-1; //Delayed spawn of the speech proc thread. 20 /* Enumeration of EZNICRX Errors */ 104 21 ♦define ERR_PAYLOADJNVALID_LENGTH 0x80INICRX_ZONE_IDI0xO 105 22 #defιne ERR-.LINEJNACTIVE 0x80INICRX_ZONE_IDI0x1 23 #defιne ERR_NO_ACK_PENDING 0x80INICRX_Z0NE_IDI0x2 24 ♦define ERR_ADDRESS_UNKNOWN Ox80INICRX_ZONE_IDI0x3 25 #defιne ERR-.UNKNOWN_DE_SCRIPT-.ADDR 0x8OINICRX_ZONE_IDI0x5 26 ♦define ERR_UNKNOWN_SI_SCRIPT_ADDR 0x80INICRX_ZONEJDI0x6 LISTING psn/lc_tιmer.h 27 ♦define ERR_PAY_TYPE_MISMATCH Ox80INICRX_ZONE_IDI0x7 28 ♦define ERR_NONSENSE_MSG 0x80INICRX_ZONE_IDI0x8 1 void tιmer2lnιt(); 29 ♦define ERR_UNSUPP0RTED_F0RMAT 0x80INICRX_ZONE_IDI0x9 2 30 ♦define ERR_MSG_TYPE_ IS ATCH 0x80INICRX_ZONE_IDI0xA 3 #defιne TIMER2_RELOAD 1000 31 ♦define ERR_PAYDATA_OOB 0x80INICRX_ZONE_IDI0xB 4 32 #defιne ERR_OWNER_ ISMATCH 0x80INICRX_ZONE_IDI0xC 5 //The PERIOD Is measured in milliSecs 33 ♦define ERR_DTMF_DIALER_BUSY Ox-0INICRX_ZONEJDI0xD 6 #defιne TIMER2-.PERIOD (TI ER2-.RELOAD/1000) 7 LISTING psn/lc_pιns. 8 9 /* Function Prototypes */ 10 ************************* 11 uchar bc_Advert(); 12 void sm_DtmfDιal(); Appendix Appendix LISTING psn/lc/timer c 46 have "void" argument lists to the scripts. 47 ♦include <regl61.h> 48 LC_PH_ADVERT_REL0AD is in increments of 10mS. ♦include <ιntrpdef.h> 49 */ ♦include . Λdefs.h" 50 ♦define LC_PH_ADVERT_REL0AD 1000 ♦include . Λglobαls.h" 51 static uint advertTimer - 2; ♦include . Λnictx h" 52 ♦include . Λnicrx h" 53 T2+=TIMER2_REL0AD; ♦include . Λzones h" 54 ♦include . Λprior.h" 55 ιf(TxTιmer){ 56 TxTimer-- ; ♦include lc_mαιn. h" 57 } ♦include lc_tιmer h" 58 ♦include lcscrpt.h" 59 ιf(CιdTιmer){ 60 CidTimer-- ; / . * • ** . **** . *** . ** «». ** * / 61 } /* Function Prototypes */ 62 /»*•**.»*♦*•*.*•.♦»•*•**/ 63 ιf(RιngTιmer){ uchαr bc_Advert(); 64 RingTimer-- ; void sm_DtmfDιαl(); 65 } static servStruct servιces[]-{\ 66 {STD_PSN,ø,0} , 67 ιf(CwdTιmer){ } , 68 CwdTimer-- , 69 } 70 void tιmer2Inιt(){ 71 //Used for counting delays /*******♦**.*♦**/ 72 ιf(--advertTιmer-»0){ //Set up for 10ms interrupts. 73 advertTimer - lC_PH_ADVERT_REL0AD; //Timer is clk'd at 1MHz 74 bc_Advert() ; T2C0N - COUNTDOWN I STD_TIMER_M0DE I PRESCALE_16; 75 } T2 - TIMER2_REL0AD; 76 T2IC » INT_ENABLE IT2_ILVL IT2_GLVL ; 77 T2R = 1 ; 78 uchar bc_Advert(){ 79 /* ***************/ servιces[0].addr node=SelfAddr; 80 //Assume that the services of the system object are 81 //universally understood. //Init all of the i fs with assoc scripts. 82 Sen pts [LC_PH_ADVERT] . fm . scri pt-LC_PH_ADVERT ; Scrιpts[LC_PH_ADVERT] scrιpt=bc_Advert; 83 Scπpts[LC_PH_ADVERT] .msgType=BROADCAST; 84 Scrιpts[LC_PH_ADVERT] . toAddr. addr node-0; 85 Scπpts[LC_PH_ADVERT] . toAddr. addr. scπpt=0; void ti erO interrupt TIMER2{ 86 Scπpts[LC_PH_ADVERT] payType=SERVICE_ENUM; /***************** • **********/ 87 Scπpts[LC_PH_ADVERT] payLen-sizeof (servStruct); /* 88 Scπpts[LC_PH_ADVERT] up payPtr=(uchar*)servιces; This is a "void event" dispatcher and thus simply 89 fires thise scripts that are in the event zone . 90 T5IC 8.= ~INT_ENABLE; 91 postTxQueue(8.Scπ pts [LC_PH_ADVERT] ) ; Note that as a "void event" the scripts in this zone 92 T5IC I - INT.ENABLE ; Appendix Appendix 93 94 return 0; LISTING psn/lc_main. 95 } 96 1 ♦include <regl61.h> 97 void sm HmfDiαl(){ 2 ♦include <intrpdef.h> 98 /** . * . *** ... * ... */ 3 ♦include \defs.h" 99 /♦ This is α state machine triggered by a command */ 4 ♦include . Λglobals.h" 100 /* event message. As such it uses the imf Buff def'd */ 5 ♦include . Λioregs.h" 101 /* in the eznicrx module. */ 6 ♦include . Anictx.h" 102 static uchar dt fCounter; 7 ♦include . Λnicrx.h" 103 8 ♦include . Λzones.h" 104 ♦define GAP.PERIOD DtmfDigitTi e 9 ♦include . Λdbase.h" 105 10 ♦include . Λulaw.h" 106 if(DtmfIndex-=0) return; /* Idle state */ 11 ♦include . Λprior.h" 107 12 ♦include . Λcodec.h" 108 i f (Dt f Index— 0x80){ 13 ♦include . Λspch.h" 109 / ♦ Dial 1st digit*/ 14 110 Dtmf Digit-Dtmf Buff [0] ; 15 ♦include "lc_pins.h" 111 Dtmf Index - 1; 16 ♦include "lc.main.h" 112 dtmfCounter - DtmfDigitTime; 17 ♦include "lc_scrpt.h" 113 } 18 ♦include "lc_timer.h" 114 else{ 19 115 i f (--dtmfCounter— ){ 20 ♦if (TEST«=SW_TEST)I (TEST—HW_TEST) 116 / ♦ If digit timer timed out then proceed*/ 21 ♦include "lctest.h" 117 if(DtmfDigit>0){ 22 ♦endif 118 /•Setup for inter-digit gap*/ 23 119 DtmfDigit-0; 24 ♦define COMBO.DTMF 0x02 120 dtm Counter-GAP_PERIOD; 25 ♦define COMBO-CID 0x04 121 } 26 ♦define C0MB0_RING_0FF 0x08 122 else{ 27 ♦define C0MBO_RING_0N 0x10 123 /•Get next digit*/ 28 ♦define C0MB0_PRINT 0x20 124 Dtmf Di gi t-Dtmf Buff [Dtmf Index++] ; 29 125 i f (Dtmf Digit— 0){ 30 //All of these times are in millisecs 126 / ♦ End of dial*/ 31 ♦define RESEND.LIMIT 3 127 DtmfIndex-0; 32 128 /* Send CmdAck process completed */ 33 sbit postpin - P 3 Λ 3; 129 Scri pts[LC_PH_DIALSTR] . u . payData-0 ; 34 sbit postpindir = DP3 Λ 3; 130 Scripts[LC_PHJ)IALSTR].msgType-RP_ENDED 35 / ** * * *** ******** * *** * * */ 131 postTxQueue(8,Scri pts [LC_PH_DIALSTR] ) ; 36 /* Inter-Zone buffers */ 132 } 37 / *** * ***** * *** * ***** ** */ 133 else. 38 bit CodecSinkFlag.CodecSrcFlag; 134 dtmfCounter - DtmfDigitTime; 39 imfStruct Scripts[LC_TOTAL_SCRIPTS] ; 135 } 40 dtmfStruct DtmfIn; 136 } 41 uchar DtmfBuff[16]; 137 } 42 uchar DtmfDigitTime « (uchar)((int)løø/(int)TIMER2_PERI0D); 138 } 43 uchar DtmfIndex, DialMode; 139 } 44 uchar DtmfDigit; Appendix Appendix Appendix Appendix ♦endif 186 postTxQueue(_Scrιpts[LC_PH_SPCHPKT]), 187 T5IC I- INT.ENABLE, combolnito, 188 T2IC INT_ENABLE, nicRxInitO, 189 postpιn=0, nicTxInitO, 190 codecInitO, 191 tιmer2Inιt() , 192 nicTxDispO, tιmer3Inιt() , 193 IcScriptlnitO, 194 //0S/04/980545 pm Code introduced to release ModeReg = 0x02, 195 //the line if no spch pkts are received for a 196 //period of C0DEC_WATCh_D0G_TIME0UT //Initialization of various pins 197 ιf(CwdTιmer—ø){ LineSeizePinDir = OUTPUT, 198 //Release line and go to idle state LineSeizePin - 0, 199 loc_LtneSeιze(0) , 200 } ♦ if (TEST— SW_TEST)I l (TEST»-HW_TEST) 201 tιmer4Inιt(), 202 ♦endif return StatusReg, //Clear out any state } LISTING psn/lc_maιn void maιn(){ /** • ** . ****/ 1 psn/lc_maιn h 2 hwImtO, 3 extern bit CodecSinkFlag CodecSrcFlag, 4 extern imfStruct Scripts!], ♦ifdef BLOB 5 extern mailStruct SpchMailStruct, ringMai llist[0] addr node-1, 6 extern mailAddr spchMaιlLιst[], rιngMaιUιst[0] addr scrιpt-PH_RINGON0FF, 7 extern mailStruct RingMailStruct, rιngMaι lLιst[l] addr node-2, 8 extern mailAddr rιngMaιlLιst[] πngMaιlLιst[l] addr scrιpt=PH_RING0N0FF, 9 extern mailStruct CidMailStruct, RingMailStruct eol=2, 10 extern mailAddr cιdMaιlLιst[] 1 1 cιdMaιlLιst[0] addr node-1, 12 extern uchar DtmfDigit cιdMaι lLιst[0] addr scrιpt-PH_CIDDEC0DE, 1 3 extern uchar DtmfDigitTime, cιdMaιlLιst[l] addr node-2, 14 extern uchar Dtmflndex, DialMode, cιdMaιlLιst[l] addr scrιpt-PH_CIDDEC0DE, 15 extern uchar DtmfBuff[16], CidMailStruct eol-2, 1 6 extern uchar SelfAddr ♦endif 1 7 extern uint RingTimer 18 IEN-1, 19 extern dtmfStruct Dtmf, 20 whιle(l){ 21 //Enum of speech tracks ιf(CodecPostFlag){ 22 ♦define LC_BUSY 0 postpιn-1; 23 ♦define PICKUP 1 CodecPostFlag-ø; 24 ♦define ST ART_CALL 2 T2IC &- -INT.ENABLE ; 25 ♦define INVALID 3 T5IC 8.= ~INT_ENABLE , 26 #define BING 4 Appendix Appendix ♦define PH_BUSY 5 31 Scπpts[LC_PH_DIALDIGITTIME] .scπpt-chl_DιalDιgιtTιme; 32 Scrιpts[LC_PH_DIALMODE] .scrιpt=chl_DιalMode; ** * * ** * * * * * * ** ** * *** *** * * 33 Scrιpts[LC_PH_DIALSTR] scrιpt-ch2_DιalStr; /* Function Prototypes */ 34 Scπpts[LC_RINGMAILLIST] scrιpt=chl_RιngMaι lLιst ; 35 Scrιpts[LC_RINGMAILLIST] .maιlPtr=&RιngMaιlStruct; void encodeSpchO; 36 Scπpts[LC_CIDMAILLIST] scπpt-chl_CιdMaιlLιst; void replayTrack(); 37 Scπpts[LC_CIDMAILLIST] maιlPtr-_CιdMaι lStruct ; void dtmfGenO; 38 Scrιpts[LC-LINESEIZE] scπpt=chl_LιneSeιze; 39 Scrιpts[LC_LINESEIZE] .scrι t=.chl_LιneSeιze; ** ****** **** * *** **** * *** * 40 Scrιpts[LC_RINGDET] scrιpt-(scrιptPtr)de_RιngDet; /* Globals V 41 Scπpts[LC_CIDPKT] scrιpt=(scπptPtr)de_CιdPkt ; 42 } extern uchar CodecTxCoπtrol; 43 44 / * ** ******************** * * * ************** * *********** * ** * ** * ***** * ** * * 45 /* Child Process Scripts ♦/ LISTING psn/lc_scrιpt c 46 *********************************************************** t ***^* ^ t * 47 // Reminder of RP script format of msg- ♦include <regl61.h> 48 // ImsgType I payType I payLenI payload I ♦include <iπtrpdef.h> 49 ♦include <ιntπns h> 50 ♦include ". Λdefs.h" 51 uchar chl_SpchMaιUιst(uchar* msg, imfStruct* imfPtr). ♦include ". Λglobαls.h" 52 / **************************************************** / ♦include ".Λioregs h" 53 ♦include ". \nictx h" 54 Syntax ♦include ". \nicrx h" 55 ♦include ".Λdbαse h" 56 msgType- RP_SPAWN ♦include ".Λulαw.h" 57 ♦include " Azones h" 58 payType UNSIGNED_CHAR ♦include ". Λpπor h" 59 ♦include ". \codec.h" 60 payLen TURN_0N : ♦if DEBUG_OUT==UART 61 TURN_0FF: ♦include " Xuαrt.h" 62 ♦include ' \≤trutιls h" 63 payLoad ιf(TURN_0N) dest,ON,format ♦endif 64 ιf(TURN.OFF)- dest,OFF 65 where: ♦include "lc_pιns h" 66 dest is an address{node,script} ♦include "lc_mαιn.h" 67 ♦include "lc_scrpt.h" 68 returns: ø success ♦include ' lc_tιmer h" 69 various errors 70 uint CidTi er; 71 Comment 72 void lcScrιptInιt(){ 73 - If this function is used to deplete the mailing /******************/ 74 list down to zerothen an automatic line release is //Init all of the imfs with assoc scripts. 75 executed. Scrιpts[LC.PH_SPCHMAILLISr).script-chl_SpchMaιlLιst; 76 Scrιpts[LC_PH_SPCHMAILLIST] mailPtr-SSpchMailStruct; 77 Only ULAW_ENC0DED currently supported Appendix Appendix 78 125 LιneSeιzePιn-0; 79 05/17/9809:04 am 126 } 80 127 } 81 Add coded to ensure that the line has been seized 1 28 else{ 82 prior to add members to the list. 129 ♦if DEBUG..0UT— UART 83 */ 1 30 putsUart2("\rErr: non-sense msg" , fName); 84 uint temp; 131 ♦endif 85 address target; 1 32 return ERR_NONSENSE_MSG; 86 ♦if DEBUG_0UT—UART 1 33 } 87 static const uchar fName[] - "chl_SpchMaιlLιst"; 134 break, 88 ♦endif 135 89 1 36 case 4: 90 ιmfPtr->fm script - LC_PH_SPCHMAILLIST, 1 37 / ♦ ---•/ 91 138 //Turn on the stream 92 ifCLineSeizePin—0){ 139 ιf(*msg++.—SPCH_FL0W_0N){ 93 //Cannot add members to spch list 140 swιtch(*msg){ //This is format. 94 //if line not seized. 141 case ULAW_ENCODED: 95 return ERR_LINE_INACTIVE; 142 /* •/ 96 } 143 //Add to the mailing list 97 144 98 swιtch(*msg++){ //switch on <msgType> 145 i f (temp-processMaιl(ADD_T0_4MAIL_LIST, target, &Scπpts[LC_PH_SPCHPKT])){ 99 case RP_SPAWN: 146 break; 100 /* */ 147 } 101 //PayType 148 CodecSιnkFlag=CodecSrcFlag=l; 102 ιf(*msg++ != UNSIGNED_CHAR){ 149 break; 103 ♦if DEBUG.OUT—UART 1 50 104 putsUart2("\rErr <PAY_TYPE> mismatch in ",fName); 1 51 default: 105 ♦endif 1 52 /* •/ 106 return ERR_PAY_TYPE_MISMATCH; 1 53 ♦if DEBUG.OUT—UART 107 } 1 54 putsUart2("\rErr: Unsupported format m ",fName); 108 1 55 ♦endif 109 ♦define PAY_LEN temp 1 56 return ERR_UNSUPPORTED_FORMAT; 110 PAY_LEN=*msg++; 1 57 } 111 1 58 } 112 //Extract the target address 1 59 else{ 113 target node-*msg++; 160 ♦if DEBUCOUT—UART 114 target. senpt-*msg++; 1 61 putsUart2("\rErr: non-sense msg« in ",fName); 115 1 62 ♦endif 116 swιtch(PAY_LEN){ //This is a switch on <PAY_LEN>. 163 return ERR_NONSENSE_MSG; 117 case 3: 1 64 } 118 165 break, 119 //Turn off the stream 166 120 ιf(*msg—SPCH_FLOW_OFF){ 1 67 default: 121 168 / ♦ -—•/ 122 temp-processMaιl(REMOVE_FROM_MAIL_LIST,target > 8,Scrιpts[LC_PH_SPCHPKT]); 1 69 ♦ if DEBUG_0UT— UART 123 if(SpchMaiIStruct.eol— ){ 1 70 putsUart2("\rErr: Invalid <PAY_LEN> in " ,fName) ; 124 CodecSrcFlag-CodecSinkFlag-ø; 171 ♦endif Appendix Appendix return ERR_PAYLOAD_INVALID_LENGTH; 219 swιtch(*msg++){ //switch on <msgType> } 220 case RP-SPAWN break; 221 / . . / 222 //PayType default : 223 ιf(*msg++ '= UNSIGNED_CHAR){ /* */ 224 ♦if DEBUG_0UT—UART ♦ if DEBUG_0UT— UART 225 putsUart2("\rErr- <PAY_TYPE> mismatch in ",fName); putsUart2("\rErr: <MSG_TYPE> mismatch in " ,fName) ; 226 ♦endif ♦endif 227 return ERR_PAY_TYPE_MISMATCH; return ERR_MSG_TYPE_MISMATCH; 228 } } 229 ♦define PAY_LEN temp return temp, 230 PAY-.LEN=*msg++; 231 lf(PAY_LEN '- 3){ 232 ♦if DEBUG_OUT=-UART uchar chl-RιngMaιlLιst(uchar* msg, imfStruct* ιmfPtr){ 233 putsUart2("\rErr. invalid <PAYLEN> in ",fName); /******* » ******** •* **** « * . * #* ***** ** * * * * ******* **• ***/ 234 ♦endif 235 return ERR_PAYLOAD_INVALID_LENGTH; Syntax 236 } 237 msgType: RP-.SPAWN 238 target node=*msg++; 239 target scπpt-*msg++; payType: UNSIGNED_CHAR 240 241 swιtch(*msg){ //action payLen : 242 case 0 243 return payLoad- <NodexScrιpt><Actιon> 244 processMaιl(REMOVE_FROM_MAIL_LIST,target,8,Scπpts[LC_RINGMAILLIST]); where Action :« 1 for ADD 245 Action - 0 for REMOVE 246 case 1 247 return returns: 0 success 248 processMaιl(AOD_TO_MAIL_LIST,target,&Scrιpts[LC_RINGMAILLIST]); various errors 249 250 default: Comment 251 return ERR_MSG_TYPE_MISMATCH; 252 } Provides the addition and deletion of a list 253 break, of mailing addresses to the ring service The 254 message can come from anywhere - this is a generic 255 default information service 256 / ♦ */ */ 257 ♦if DEBUG-OUT—UART uint temp, 258 putsUart2('\rErr: <MSG_TYPE> mismatch in ".fName); address target; 259 ♦endif ♦if DEBUG-.0UT—UART 260 return ERR_MSG_TYPE_MISMATCH; static const uchar fName[] - "chl_RιngMaιlLιst"; 261 ♦endif 262 263 ιmfPtr->fm script - L RINGMAILLIST; 264 uchar chl_CιdMaιUιst(uchar* msg, imfStruct* imfPtr) . 265 /********************************************ι*mm . Appendix Appendix 266 313 return ERR_PAYLOAD_INVALID_LENGTH, 267 Syntax: 314 268 315 269 msgType: RP_SPAWN 316 target node=*msg++; 270 317 target scπpt-*msg++; 271 payType: UNSIGNED_CHAR 318 272 319 swιtch(*msg){ //action 273 payLen . 3 320 case 0 274 321 return 275 payLoad: <NodexScrιpt><Actιon> 322 processMaι l(REM0VE_FR0M_MAIL_LIST,target ,8,Scrιpts[LC_CIDMAILLIST]) , 276 where Action :- 1 for ADD 323 277 Action - 0 for REMOVE 324 case 1 278 325 return 279 returns: 0 success 326 processMai l(ADD_TO_MAIL_LIST , target ,8,Scripts[LC_CIDMAILLIST]) ; 280 various errors 327 281 328 default: 282 Comment 329 return ERR_MSG_TYPE_MISMATCH; 283 330 } 284 Provides the addition and deletion of a list 331 break, 285 of mailing addresses to the ring service. The 332 286 message can come from anywhere - this is a generic 333 default 287 information service. 334 /* */ 288 */ 335 ♦if DEBUG-OUT—UART 289 uint temp; 336 putsUart2("\rErr: <MSG_TYPE> mismatch in ",fName), 290 add ress target ; 337 ♦endif 291 ♦if DEBUG_0UT— UART 338 return ERR_MSG_TYPE_MISMATCH; 292 static const uchar fName[] - "chl_CιdMaιlLιst" ; 339 293 ♦endif 340 294 341 295 ιmfPtr->fm script - LC_CIDMAILLIST; 342 296 343 uchar chl_DιalDιgιtTιme(uchar* msg, imfStruct* imfPtr) . 297 tch(*msg++){ //switch on <msgType> 344 /********************************************* t t m**y 298 case RP_SPAWN: 345 /* 299 /* • / 346 Syntax 300 //PayType 347 301 ιf(*msg++ !- UNSIGNED_CHAR){ 348 msgType RP.SPAWN 302 ♦ if DEBUG.OUT— UART 349 303 putsUart2("\rErr- <PAY_TYPE> mismatch in " , fName) 350 payType UNSIGNED.CHAR 304 ♦endif 351 305 return ERR-PAY TYPE-MISMATCH; 352 payLen 1 306 } 353 307 ♦define PAY-.LEN temp 354 payLoad DigitTime in 10s millisecs 308 PAY_LEN-*msg++ ; 355 309 lf(PAY_LEN '- 3){ 356 returns 0 success 310 ♦if DEBUG_0UT— UART 357 various errors 31 1 putsUart2("\rErr- invalid <PAYLEN> in " ,fName) ; 358 312 ♦endif 359 Comment Appendix Appendix oooiOr- cvir - miDi^oocnθ— CMro rL u t-oo nθ— ιsιro^-ιnu.s ooιθ4- (sjrnfo -r4--τr 454 } 501 various errors 455 502 456 swιtch(*msg){ 503 Comment 457 case 0: 504 458 /•-— ♦ / 505 Dials string using the currently selected dialing mode. 459 DialMode - DTMF_M0DE; 506 02/03/98 01-56 pm - Currently only supports DTMF dial . 460 break; 507 */ 461 508 462 case 1: 509 char c , 463 /*—*/ 510 uint l .payLen; 464 DialMode - PULSE.MODE; 51 1 ♦if DEBUG.OUT--UART 465 break; 512 static const uchar fNa eQ - "ch2_DιalStr" ; 466 51 3 ♦endif 467 default 514 468 /•---•/ 51 5 ιmfPtr->fm script - LC.PH_DIALSTR; 469 ♦ if DEBUG-.0UT— UART 516 470 putsUartZ("\rErr: Invalid <PAY_DATA> in " , fName) 51 7 ιmfPtr->msgType=RP_STARTED; 471 ♦endif 518 472 return ERR PAYLOAD INVALID_LENGTH; 519 swιtch(*msg++){ //switch on <msgType> 473 } 520 case RP_SPAWN. 474 break; 521 /* */ 475 522 //PayType 476 default: 523 ι (*msg++ !» UNSIGNED_CHAR){ 477 / ♦ */ 524 ♦ if DEBUG.OUT— UART 478 ♦ if DEBUG.OUT— UART 525 putsUart2("\rErr: <PAY_TYPE> mismatch in " , fName); 479 putsUart2("\rErr: <MSG_TYPE> mismatch in " , fName) ; 526 ♦endi f 480 ♦endif 527 return ERR_PAY_TYPE MISMATCH; 481 return ERR_MSG_TYPE_MISMATCH; 528 } 482 } 529 483 return 0, 530 ι f(DιalMode*=DTMF_MODE){ 484 } 531 i f (Dtmf Index— 0){ 485 532 payLen - *msg++; 486 uchαr ch2_DιalStr(uchar* msg, imfStruct* imfPtr){ 533 for(ι=0;κpayLen;ι++){ 487 ************************************ ****** ******* 534 /• Check that content is ASCII */ 488 /* 535 c - *msg++; 489 Syntax - 536 ι f(((a». , ø' )&&(c<= , 9' ))l l 490 537 ((c>-'A')&8.(c<-'D'))l l 491 msgType: RP_SPA N 538 (c— *r ) M 492 539 0 -' * ' )){ 493 payType: ASCII 540 *(DtmfBuff+ι)=c; 494 541 } 495 payLen : >1 542 else{ 496 543 ♦if DEBUG.OUT-=UART 497 payLoad: ASCII string. 544 putsUart2("\rErr: Non DTMF digit in " , fName); 498 545 ♦endif 499 returns: RP_STARTED 0 — success 546 return ERR-PAYDATA OOB; 500 RP-.ENDED 0 — success 547 } Appendix Appendix 548 } 595 payLen = 549 *(DtmfBuff+ι)-0; /* Terminating zero 596 550 Dtmflndex-0x80; /* Set "start dial bit 597 payLoad 0 go on hook. 551 } 598 1 go off hook. 552 else{ 599 553 ♦ if DEBUG_OUT«UART 600 returns 0 successfully seized/released the line 554 putsUart 2 ("\rErr: Dial busy in ",fName); 601 1 busy 555 ♦endif 602 556 return ERR_DTMF_DIALER_BUSY; 603 */ 557 } 604 ♦if DEBUG_0UT==UART 558 } 605 static const uchar fNameQ - "chl_LιneSeιze" ; 559 break, 606 ♦endif 560 607 uint streamlndex, 561 default: 608 bit foundFlag, 562 / ♦ */ 609 563 ♦if DEBUG_0UT—UART 610 ιmfPtr->fm script - LC_LINESEIZ£; 564 putsUartZ( ΛrErr: <MSG_TYPE> mismatch in ",fName); 61 1 565 ♦endif 612 swιtch(*msg++){ //switch on <msgType> 566 return ERR_MSG_TYPE_MISMATCH; 613 case RP_SPAWN 567 614 / « 568 return 0, 615 //PayType 569 } 61 6 ιf(*msg++ '= UNSIGNED.CHAR){ 570 617 ♦if DEBUG_0UT=»UART 571 void loc_LιneSeιze(uchar actιon){ 618 putsUart2("\rErr <PAY_TYPE> mismatch in ",fName); 572 /****** * ** * * * *** * ** ** * * ** **** *** */ 619 ♦endif 573 //05/0V98 05: 3 pm 620 return ERR_PAY_TYPE_MISMATCH; 574 //Locally callable version of the child script below 621 } 575 ιf(actιon==0){ 622 ιf('msg++ I- 1){ //check paylen 576 LιneSeιzePιn-0, 623 ♦if DEBUG_0UT==UART 577 SpchMaiIStruct .eol-0; 624 putsUart 2 ( rErr: <PAY_LEN> mismatch in ", Name); 578 CodecSrcFlag=CodecSιnkFlag»0; 625 ♦endif 579 } 626 return ERR_PAY_TYPE_MISMATCH; 580 else{ 627 } 581 LιneSeιzePιn=l; 628 582 SpchMaiIStruct eol-0; 629 swιtch('msg){ 583 } 630 case 0 584 } 631 /•---•/ 585 632 LιneSeιzePιn«0; 586 uchar chl_LιneSeιze(uchar* msg, imfStruct* imfPtr){ 633 SpchMaiIStruct.eol-0; 587 /**************************************************/ 634 CodecSrcFlag=CodecSιnkFlag-ø; 588 635 break, 589 Syntax- 636 590 637 case 1 591 msgType: RP.SPAWN 638 /*--- ♦ / 592 639 //05/21/98 Add'n qual : return busy if ring active and 593 payType : UNSIGNED-.CHAR 640 //msg is NOT fm node on the mailing list 594 641 ι f(RιngTιmer){ Appendix Appendix 642 //This PSN is being called by CO, check that 689 ♦if DEBUG_0UT— UART 643 //this msg is coming from a src on the mailing list 690 putsUart2( ΛrErr: <MSG_TYPE> mismatch in " , fName) ; 644 foundFlag-0; 691 ♦endif 645 692 return ERR_MSG_TYPE_MISMATCH; 646 for(streamIndex-0;streamIndex<RingMailStruct.eol ,streamIndex++){ 693 } 647 //"ιmfPtr->toAddr. addr. node" is the FMNODE and is wπtten 694 return 0; 648 //by the calling routine "nicrx.c" . 695 649 ιf(rιngMaιlLιst[streamIndex_ addr node==ιmfPtr- 696 650 >toAddr . addr . node){ 697 651 foundFlag=l; 698 652 break; 699 ************** **********************^******** 4 444* 4 4 4 4 4444 * 4 * 4444 ** / 653 } 700 /* Data Event Receptor Scripts */ 654 } 701 /* *** * * **************** • *********** ** * * *************** * ** * ******** * ** , 655 lf(foundFlag-«0){ 702 ♦define SDMF 0x4 656 return 1; //BUSY 703 ♦define MDMF 0x80 657 } 704 ♦define CID_BUFF_SIZE 40 658 } 705 uchar CidBuff[CID_BUFF_SIZE]; 659 706 void de_CιdPkt(){ 660 i f ((SpchMai IStruct . eol— 0)){ 707 /*♦*♦»*♦♦#*♦***»/ 661 LιneSeιzePin-1; 708 ♦define DEB0UNCE 8 662 SpchMai IStruct . eol-0; 709 663 CwdTimer - C0DEC_WATCH_DOG_TIMEOUT; 710 //Timeout is in millisecs 664 } 71 1 ♦define CID_TIME0UT 1000 665 else{ 712 666 return 1; //PSN busy. 71 3 enum{CID_IDLE ,CID_LINE_SEIZE,CID_MSG_LEN,CID-.GET_DATA} ; 667 } 714 static uchar cidState,count,index; 668 break; 71 5 static uchar rxChar; //static ONLY to overcome compiler bug. 669 716 670 case 2: 717 ιf(CιdTιmer»=0){ 671 /* •/ 718 cιdState=CID_IDLE; 672 //05/28/9802:38 pm INcluded to re-fresh the codec watchdog for 719 } 673 //handling conf calls. 720 674 CwdTimer - CODEC_WATCH_DOG_TIMEOUT; 721 rxChar=CιdReg; 675 break; 722 swιtch(cιdState){ 676 723 case CID-.IDLE: 677 default. 724 /* */ 678 / ♦ ---*/ 725 ιf(rxChar==0x55){ 679 ♦if DEBUG.0UT—UART 726 cιdState-CID_LINE_SEIZE; 680 putsUart2("\rErr: Invalid <PAY_DATA> in ".fNa e); 727 count-0; 681 ♦endif 728 682 return ERR_PAYLOAD_INVALID_LENGTH; 729 683 730 684 } 731 685 break; 732 case CID .INE-.SEIZE: 686 733 /. ./ 687 default: 734 swιtch(rxChar){ 688 / ♦ */ 735 case SDMF : Appendix Appendix E - σ* ιnιtScπpts(smsNode , LC_PH_SPCHMAILLIST) , 71 else{ //Set up the pαrαms 72 ProblemNodeArray[ProblemNodeIndex++]-smsNode; Scripts [PH.APPINTF] . pαyLen-3 ; 73 reSendCount-0; //Ensure we cont the search αppBuffrø-SelfAddr; //IThe address of the 74 PhPtr-phldle; appBuff[l]=LC_PH_SPCHSINK; //I script to be removed 75 SpchMai IStruct eol - 0, appBuf f [ 2 ]=SPCH_FL0W_0FF ; 76 Scπpts[PH_APPINTF] up payPtr-appBuf ; 77 postTxQueue(SScπpts[PH_APPINTF]) ; 78 PhPtr=phRpeExιt, 79 } else{ //Once we get to the end of our SpchMailList LISTING phone/sιg_g //reset everything and go idle Spch ailStruct.eol - 0; 1 #ιfdef SCAN_BUFF //Retire to idle state 2 //l» DEBUG PhPtr = phldle, 3 //Scan the out-going pkt for large smpl values } 4 for(ptr=Scrιpts[LC_PH_SPCHPKT] up payPtr; 5 ptr<(Scrιpts[LC_PH_SPCHPKT] up payPtr+6 ); 6 ptr++){ void phRpeExιt(){ 7 /***************/ ιf«*ptr_0x7F)<0x20)( 8 TxPιn=1 , //This is the RPE for removing "self" from the various 9 TxPιn=0, //mailing lists 10 I #ιfdef SM_TRACE 1 1 I dιsplayState( phRpeExit ), 12 #eπdιf #endιf 13 14 #ιfdef SIG-.GEN ιf((PhnAppTιmer— 0) 1 l (Scrιpts[PH_APPINTF] rpError--l)){ 15 //l» DEBUG goto LblErrorRecover, 16 //Generate a test ramp at 500Hz } 1 7 c=0, 18 for(ptr=Scπpts[LC_PH_SPCHPKT] up payPtr; if (Scπpts[PH_APPINTF] . rpEnded){ 19 ptt <(Scrιpts[LC_PH_SPCHPKT] up payPtr+6 ), Sen pts [PH.APPINTF] . rpEnded-0; 20 ptr++){ ιf((Scπpts[PH_APPINTF] payLen—l)&&\ 21 sιg=(ιnt)c « A, (Scπpts[PH_APPINTF] up payData— 0)){ 22 *ptr = ImToU(sιg), smslndex++; 23 c+= 1 6, reSendCount-0, 24 I PhPtr=phRpsExιt, 25 #endιf } 26 else{ 27 #ιfdef CONST LblErrorRecover- 28 //"I DEBUG /* */ 29 //Generate a test ramp at 500Hz. //Back up the index to resend 30 for(ptr=Scrιpts[LC_PH_SPCHP T] up payPtr; if(reSendCount<RESEND_LIMIT){ 31 ptr<(Scrιpts[LC_PH_SPCHPKT] up payPtr+6 ), reSendCount++; 32 ptr++)| PhPtr-phRpsExit; 33 *ptr = 0x55, } 34 Appendix Appendix #endιf LISTING phone/ph_tιmer h 1 void tιmer2lnιt(), LISTING phone/sιg_vars c 2 3 #defιne TIMER2_RELOAD 1000 //#defιne CONST #ιfdef POLL-.HOOK 6 #defιne TIMER2_PERI0D (TIMER2_RELOAD/1000) #endιf 8 *********************** / 9 /* Function Prototypes */ #ιfdef SIG-.GEN 10 //"'DEBUG 11 uchar bc_A vert(), ulaw* ptr, 12 void sm_DtmfDιal(), static uchar c; 13 int sig, 14 / *********** / #endιf 15 /* Globals */ 16 ************* #ιfdef CONST 17 extern bit RingEnable, //MIDEBUG ulaw* ptr; LISTING phone/ph_sm_sc #endιf 1 void smAddToGrp(uchar node, phStatePtr retState); LISTING phone/ph_scrιpt h 2 #define SC-.0K 0 ************************* 3 #defιne SC_ERR0R OxFF /* Function Prototypes */ ************************* LISTING phone/ph_sm_gl void phScπptlnitO; void smGetLιne(phStatePtr retState); uchar ch1_SpchFlow(uchar* msg, imfStruct* imfPtr); void glRpsGetPsnO, uchar ch1_SpchMaιlLιst(uchar* msg, imfStruct* imfPtr); void glRpeGetPsnO, uchar chl_de_RιngOnOff( uchar* msg, imfStruct* imfPtr); uchar ch1_HookReceptor(uchar* msg, imfStruct* imfPtr); #defιne GL_ALL_LINES_BUSY OxFF uchar ch1_DιalDιgιtTιme(uchar* msg, imfStruct* imfPtr); extern uchar GIRetValue, uchar chl_DιalMode(uchar* msg, imfStruct* imfPtr); uchar ch2_DιalStr(uchar* msg, imfStruct* imfPtr); LISTING phoπe/ph_sm_ss uchar chl_Applntf( uchar* msg, imfStruct* imfPtr); uchar pp_CιdDecode(uchar *msg, imfStruct* imfPtr); 1 void smPrιvCoπnect(uchar node, phStatePtr retState); 2 void smlnιtConnect(uchar node, phStatePtr retState); char getTιme(uchar* msg); 3 void pcRpsSpchOnQ; void getNumber(uchar* msg); 4 void pcRpeSpchOn(), void getName(uchar* msg, uchar len); 5 void clockO; 6 extern uchar PcRetValue, void pπntTimeO; 7 8 #defιne PC_OK 0 9 #defιne PC_ERROR OxFF Appendix Appendix LISTING phone/reLline c 46 //the line we want to continue 47 void phRpsRelLιne(){ 48 *********** * ** * ****/ 49 #lfdef SM.TRACE 50 dιsplαyStαte( phRpsRelLine ), #endιf LISTING phone/ph_sm_ss //Release line 1 ιnιtScπpts(spchMaιlLιstf0_ addr πode,LC_LINESEIZE), 2 Call sign pc (single speech connect) Scπ ts[PH_APPINTF] payLen-1, 3 Function Scπpts[PH_APPINTF] .up payData-0, 4 SM that establishes a stream between self and postTxQueue(SScrιpts[PH_APPINTF]), 5 specifically identified node This SM adds self PhPtr=phRpeRelLιne, 6 to the mailing list of target but NOT to the 7 mailing list of self 8 Args voi d phRpeReUιne(){ 9 pcNode=Node address new member /** ****** * **** *** * 10 #ιfdef SM.TRACE 11 Returns(vιa pcRetValue) dιsplayState( phRpeRelLine ), 12 PC_0K #endιf 13 PC-.ERR0RS 14 ιf((PhnAppTιmer==0)l l(Scπpts[PH_APPINTF] rpError—1)){ 15 //Node not responding, note the problem 16 //and move on 17 ^include \globals goto LblErrorRecover, 18 } 19 if(Senpts[PH-APPINTF] rpEnded—1){ 20 ι f((Scπpts[PH_APPINTF] payLen— 1) MX 21 (Scπpts[PH_APPINTF] up payData— 0)){ 22 //Line released - proceed 23 ph_maιn h PhPtr-phGetSecondKey , 24 #ιnclude ph sm pt h } 25 ^include ph sm ss h else{ 26 LblErrorRecover 27 uchar pcNode, / . » / 28 uchar reSendCount, if(reSendCount<RESEND_LIMIT){ 29 uchar PcRetValue, reSendCount++, 30 phStatePtr pcRetState, PhPtr=phRpsRelLιne, 31 } 32 void smPrιvConnect(uchar node, phStatePtr retState){ else{ 33 / ********* * ******** ** * * * * ** ** ** *** * ** ** ** ** ** * *** * * * //Abandon trying to reach this node 34 //A private conection used mainly by the conf call //Report problem, modify own database 35 //state machine //and proceed to look for next PSN 36 PπvateFlag=l, logProblem(PSN_NODE_NUM), 37 Pπ vateNode=node , reSendCount-0, //Ensure we cont the search 38 pcNode = node , PhPtr=phGetSecondKey, //Even though problems in releasing 39 reSendCount = 0, Appendix Appendix pcRetStαte-retStαte; 87 PhPtr-pcRpsSpchOn, 88 void pcRpeSpchOn(){ } 89 /*•*****••******♦*/ 90 #ιfdef SM_TRACE void smInιtConnect(uchαr node, phStatePtr retState){ 91 dιsplayState( pcRpeSpchOn") ; ^(*t*4****************(**»******4*»***f***»********/ 92 #endιf //Routine to provide the initial connection 93 PπvateFlag=0; 94 ιf(PhπAppTιmer==ø){ pcNode = node; 95 //Node not responding, note the problem reSendCount - 0; 96 //and move on. pcRetState=retState; 97 goto LblErrorRecover; PhPtr=pcRpsSpch0π; 98 } } 99 100 ιf(Scrιpts[PH-APPINTF] rpError—1){ void pcRpsSpch0n(){ 101 /* **** * ** * ** * * ** * */ /*********** ** ****/ 102 /* SM Exit Point */ address target; 103 y ***************** y 104 PcRetValue=Scπpts[PH_APPINTF] up payData; #ιfdef SM..TRACE 105 PhPtr-pcRetState; dιsplayState( pcRpsSpchOn"); 106 return , #eπdιf 107 } 108 crιpts[PH_APPINTF] up payData—ø)){ IT){ ure' below •**/ x in pcRpeSpchOnO") ; Appendix Appendix 1 1 1 retStat ma lists group Appendix Appendix 89 ♦ifdef SM.TRACE 136 processMai I (ADD_TO_MAIL_LIST , target ,8.Scπ pts [LC_PH_SPCHPKT]) ; 90 displαyStαteC scRpsSpch0n2' ); 137 91 ♦endif 138 /****« Exit Point »** » */ 92 139 ScRetValue-SCOK, 93 ιf(reSendCount=-0){ 140 PhPtr=scRetState, 94 cαIIingStαte-scRpsSpch0n2, 141 } 95 } 142 96 else{ 143 void scRpeSpch0n(){ 97 goto LblReTx, 144 98 } 145 /* 99 i f(smlIndex<SpchMαιIStruct eol){ 146 Notes on the error handling strategy for this state: 100 LblReTx 147 This state is called by a number of states within 101 /* */ 148 the machine, some of these states cycling through 102 //reminder- ιnιtScπpts(toNode,toScrιpt) 149 the current members of the call. 103 ιnιtScrιpts(spchιαιlLιst[smlIndex] αddr node,LC_PH_SPCH4MAILLIST), 150 In all cases however prior states have established 104 //Set up the pαrαms 151 communication through LINESEIZE" or ringing etc 105 ScπptsfPhLAPPINTF] pαyLen=4, 152 If we discount for the moment the possibility that 106 AppBuff[0 scNode, 153 a node will break during the call then all that is 107 AppBuff[l LC_PH_SPCHSINK, 154 required of this state is a msg retry 108 AppBuff[2]-SPCH_FL0W_0N; 155 */ 109 AppBuf f[3]=ULAW_ENC0DED; 156 ♦ifdef SM TRACE 110 Scπpts[PH.APPINTF] .up pαyPtr-AppBuff , 157 dιsplayState( scRpeSpchOn' ), 111 postTxQueue(8.Scπpts[PH_APPINTF]); 158 ♦endif 112 PhPtr=scRpeSpchOn; 159 113 } 160 ιf(PhnAppTιmer==0){ 114 else{ 161 //Node not responding, note the problem and move on 115 PhPtr=scSpchOn 3 , 162 ♦if DEBUG_OUT==UART 116 } 163 putsUartC \rError scRpeSpchOn- Response time out"); 117 164 ♦endif 118 165 goto LblErrorRecover, 119 void scSpchOn 3 (){ 166 120 } 167 121 //♦ 3 - Put new part on self's mailing list 168 ι (Scrιpts[PH_APPINTF] rpError—l){ 122 169 ****************** 123 address target; 170 /* SM Exit Point */ 124 ♦ifdef SM_TRACE 171 ******************* 125 dιsplayState( scSpch0n3"); 1 2 ♦if DEBUG_OUT-=UART 126 ♦endif 173 putsUart( \rError scRpeSpchOn: Error bit set"), 127 174 ♦endif 128 callιngState=scSpch0n3, 175 ScRetValue=Scπpts[PH_APPINTF] up payData, 129 176 PhPtr=scRetState, 130 //Enable the spch flow and put 1 7 return, 131 //the target psn on local spch mailing list 178 132 } target node-scNode, 179 133 target scrιpt=LC >H_SPCHSINK, 180 ιf(Scπpts[PH_APPINTF].rpEnded){ 134 181 Scπpts[PH-.APPINTF] rpEnded-0, 135 //Add to own mailing list 182 Appendix Appendix 183 ιf((Scπpts[PH_APPINTF] .payLen— l)&_(Scrιpts[PH_APPINTF_ up pαyDαtα-=0)){ 184 s llπdex++; 8 void smSeqActiveQ) 185 PhPtr=cαllιπgStαte; 186 } LISTING phone/ph_sm_gl 187 else{ 188 LblErrorRecover: 1 189 /♦ »/ 2 /* Get Line State Machine •/ 190 ιf(reSendCount—RESEND.LIMIT){ 3 /* */ 191 //See "Actions on Failure" below 4 /* Call sign gl */ 192 logProblem(scNode); 5 /* Args: none, */ 193 / ♦ **•« Exit Point »•***/ 6 /* Function */ 194 ScRetValue-S ERROR; 7 /• Search the net for an available PSN If •/ 195 PhPtr ^ scRetState; 8 /* found seize the line and return the node */ 196 } 9 /* address */ 197 else{ 10 Returns(vιa GlRetValue)- */ 198 reSendCount++; 1 1 /* 0 = All PSNs busy */ 199 PhPtr-callingState; 1 2 /* >0 = Node number of the PSN */ 200 ♦if DEBUG_OUT--UART 1 3 /* Return State- */ 201 putsUart("\rErr: Bad rx in scRpeSpchOnO") ; 14 /* glRetState •/ 202 ♦endif 1 5 203 } 16 204 } 1 7 ♦include ' Nglobαls h" 205 18 ♦include " \defs h' 206 19 ♦include ' Λdbαse h" 207 20 ♦include " h ' 208 21 ♦include " h 209 Actions on Failure 22 ♦if 210 23 ♦inc 211 Given that this SM is adding new members to an existing 24 ♦inc h" 212 mailing list there should be no issue as to whether we can 25 ♦end 213 connect with a particular node. However in the unlikely 26 ♦include ' ph_mαιn h ' 214 even that a node goes down during the include of a new member 27 ♦include ph_sm_gl h 215 of the conf call, the action is to: 28 216 - add the problem node to the ProblemNodeArray[] 29 /**** Return Vαrs ****/ 217 - continue processing with other memebers of the call. 30 uchαr GIRetVαlue, 218 - do not delete from data base at this time as there is 31 219 nothing of consequence to be gained. 32 /•** ♦ Local Globals ****/ 220 33 static uchar dblndex, reSendCount; 34 static servStruct ss; LISTING phone/spch_seq c 35 static phStatePtr glRetState; 36 typedef void (*seqFPtr)(); 37 d smGetLιne(phStatePtr retState){ 38 /**** * *************** * ******* * ** ** * void smSeqPlayOI 39 glRetState-retState; seqlndex=.0; 40 dbIndex=reSendCount-0 ; seqState=>. 41 PhPtr=glRpsGetPsn; 42 ss servιce=STD_PSN; Appendix Appendix 90 ♦endif 91 void glRpsGetPsn(){ 92 ♦ifdef SM.TRACE /*****************/ 93 dιsplayState( \rglRpeGetPsn' ); uint i ; 94 ♦endif 95 ♦ifdef SM_TRACE 96 ιf(PhnAppTιmer==0){ dιsplαyStαte("\rglRpsGetPsn"); 97 //Node not responding, note the problem ♦endif 98 //and move on. 99 ♦i fdef SM.TRACE ιf(reSendCount==ø){ 100 dιsplayState( rTimeOut in glRpeGetPsn"); //If there have been no erroneous msg xchg 101 ♦endif //look up the next available PSN. 102 goto LblErrorRecover, LblSearchAgain- 103 / • • / } 104 dblndex - dbSearchServιce(dbIndex,_ss); 105 if(Scπpts[PH_APPINTF] . rpError- -1){ ιf(dblndex !« N0T_F0UND){ 106 / * * * ********* * *** * / //See if this resource is known to be in use 107 /* SM Exit Point ♦ / //by self - search again if yes. 108 y ***************** y for(ι=0;ι<SpchMaιIStruct.eol;ι++){ 109 GlRetValue=Scπpts[PH_APPINTF] up payData; ιf(spchMaιlLιst[ι_.addr node~ss addr node){ 110 PhPtr=glRetState, dblndex++; 111 return, goto LblSearchAgain; 112 } } 113 } 114 ιf(Scπpts[PH_APPINTF].rpEnded—1){ } 115 ιf(Scrιpts[PH_APPINTF] payLen—1){ else{ 116 swιtch(Scrιpts[PH_APPINTF] up payData){ /****•* *••**•******•'****•/ 117 case 0 /* SM Exit Point ♦ / ***************** y 118 /*---*/ 119 /***************** * //All lines busy. 120 /* SM Exit Point */ GlRetValue-GL_ALL_LINES_BUSY; 121 /************** * ** * PhPtr-glRetState; 122 // Line seized. return; 123 GlRetValue-ss addr node; } 124 PhPtr=glRetState, } 125 return, ιnιtScπpts(ss addr node.LC.LINESEIZE) ; 126 Sen pts [PH_APPINTF] . payLen-1 ; 127 case 1 Scπpts[PH_APPINTF] .up payData-1; 128 /*---*/ postTxQueue(8,Scπ pts [PH_APPINTF] ) ; 129 //Line busy - start continued search PhPtr=glRpeGetPsn, 130 //from the next entry in the db. 131 dblndex++; 132 reSendCount-0; void glRpeGetPsn(){ 133 PhPtr = glRpsGetPsn; /*****************/ 134 break , ♦ if DEBUG.OUT— UART 135 uchar str[4_ , 136 default Appendix Appendix 137 1 138 LblErrorRecover 2 /* Play Track State Machine */ 139 /* */ 3 /* */ 140 //Error try α re-send of the original message 4 /* 141 //This particular script is "re-callable 5 / ♦ 142 ιf(reSendCount<RESEND_LIMIT){ 6 /* 143 reSendCount++, 7 /* Play the named track */ 144 } 8 /* Returns(vιa GlRetValue) */ 145 else{ 9 /* none */ 146 //Abandon trying to reach this node 10 /* Return State */ 147 //Report problem, modify own database 11 /* ptRetState ♦ / 148 //and proceed to look for next PSN 12 /• */ 149 dbDel(&ss), 13 ♦include <regl61 h> 150 logProblem(ss addr node), 14 ♦include \globals 151 reSendCount«ø, //Ensure we cont the search 15 ♦include \defs h 152 } 16 ♦if DEBUG_OUT=-UART 153 PhPtr=glRpsGetPsn, 17 ♦include 154 18 ♦include \strutils 155 ♦if DEBUG.OUT—UART 19 ♦endif 156 formatHexUchar(str,Scrιpts[PH_APPINTF] up payData), 20 ♦include ph_maιn h 157 putsUart2( VErr Drop thro in glRpeGetPsn(), ret val- , str) , 21 ♦include ph_pιns h 158 ♦endif 22 ♦include ph_sm_pt h 159 23 160 24 /*** Function Prototypes ****/ 161 25 void ptWaιtForTrack(), 162 26 void ptGetNextTrackO, 27 LISTING phone/ph_pιns h 28 /**** Local Globals ***•/ 29 playStruct Play, 1 #define INPUT 0 30 static uchar dblndex, reSendcount, 2 #defιne OUTPUT 1 31 static servStruct ss, 3 32 static phStatePtr ptRetState,psRetState, 4 sbit AmpEnablePin - P3 Λ 2, 33 static uint TotalTracks, 5 sbit AmpEnableDirPin- DP3 Λ 2, 34 6 35 ♦define MAX_TRACK_SEQ 16 7 sbit AdOutPin P3Λ 3 , 36 8 sbit AdOutDirPin - DP3*3, 37 //♦define R0M_START_ADDR 0x80000 9 sbit AdlnPin P3 , 38 ♦define R0M_S1ART ADDR 0x200000 10 sbit AdlnDirPin ■ DP3 , 39 11 sbit AdClkPin - P3 Λ 5, 40 //The '+1' below allows for the program 12 sbit AdClkDirPin - DP3^5, 41 static ulaw xhuge* TrkDιr[NUMBER_TRAC S+l], 13 42 14 sbit RingPin P3 Λ 7, 43 /* Vars for playing track seqs */ 15 sbit RingDirPiπ DP3 Λ 7, 44 uchar SeqTrk[MAX_TRACK_SE0J, 45 bit SpchSeqActive, LISTING phone/ph_sm_pt c 46 static phStatePtr seqState, 47 static uchar seqlndex, Appendix Appendix iΛtDscoσiOr- ,— -ιoι moιOO <r S3S^S^£2f2^ Mm '*^ ω ^∞ OT0 ^~ m 'Nr^ωr N ,oocno^r-ro-^-o-> |N -coσιo^-rv j θE(1200Hz) - 38.4 0E(Z200Hz) - 70.4 Remember this routine is only called if the phone is on hook. ♦define LF_PHI 38 ♦define HF_PHI 70 //define buffer for the private use of this function and thus //enable it to be run as a thread independent of "main" . swιtch(regenState){ case GET_NEW_BYTE: / ♦ */ //Get byte byte = *msg++; //Add start bit. if(byte8,0xl){ bιtPaι r=l; } else{ bιtPaιr=0; } regenState-SEND_DATA ; bιtCount-1 ; byte»»l; break, case SEND_DATA: / . . / bιtPaιr-byte&0x3; byte»=2 ; bιtCount+=2; ιf(bιtCount«7){ regeπState-ADD_STOP_BIT; } break; case ADD_ST0P_BIT: /*— - */ ιf(byte_0xl){ bιtPaι r=3; } else{ Appendix Appendix 32 RmgDirPm - OUTPUT, 145 146 ιf(bιtPαιr & 0x2){ 33 RingPin - 1; 147 phiDelta - HF_PHI ; 34 1 8 } 35 servιces[0] addr node=SelfAddr, 149 else{ 36 150 phiDelta = LF_PHI; 37 //Init all of the imfs with assoc scripts. 1 51 38 Scrιpts[LC_PH_ADVERT] script =bc_Advert ; } 1 52 39 1 53 whι le(smpl<26){ 40 1 54 phιAcc+-(phιDeltα«l) ; 41 155 *ptr=lιn2u(sιne[phιAcc]); 42 void timerO interrupt TIMER2 using tιmer2Regs{ /.**•**.•**••♦♦*•**»*.♦**♦*.♦****»*********♦** / 1 56 } 43 157 44 /• 45 This is a "void event" dispatcher and thus simply LISTING phone/ph_tιmer c 46 fires thise scripts that are in the event zone 47 1 ♦include <regl61.h> 48 Note that as a "void event" the scripts in this zone 2 ♦include •αntrpdef h> 49 have "void" argument lists to the scripts 3 ♦include . Λdefs h" 50 4 ♦include . Λglobαls.h" 51 PH_ADVERT_RELOAD is in increments of 10mS 5 ♦include . \nιctx h" 52 */ 6 ♦include Λmcrx h" 53 ♦define PH-ADVERT_RELOAD 1000 7 ♦include . Λzones h ' 54 static uint advertTimer » 2; 8 ♦include . \prιor h" 55 static uint tιmeTιmer=l; 9 ♦include . \uαrt h" 56 static uchar secs»58; 10 ♦include . \codec h ' 57 static uchar πngGenTimer; 1 1 ♦include ph_mαtn.h" 58 1 2 ♦include ph_scrpt h" 59 T2+-TIMER2-REL0AD; 13 ♦include ph_tιmer h" 60 14 ♦include ph_pιns h" 61 //GP timer for the phone application. 15 62 ιf(PhnAppTιmer){ 1 6 static servStruct servιces[_-{\ 63 PhnAppTimei— , 17 {STD_PHN,0,0} , 64 } 18 }; 65 19 66 //Timer for inventory speech announcements 20 bit RingEnable, 67 ιf(InventoryTιmer){ 21 68 InventoryTimer--; 22 void tιmer2Inιt(){ 69 } 23 /* * **** ** **** * * */ 70 24 //Set up for 10ms interrupts 71 //This timer is a "monostable" that is triggered by an 25 //Timer is clk'd at 1MHz 72 //incoming ring signals and determines whether ring is 26 T2C0N - C0UNT_D0NISTD_TIMER_M0DEIPRESCALE_16; 73 //or is not active 27 T2 - TIMER2_REL0AD; 74 ιf(RιngTιmer){ 28 T2IC = INT_ENABLEIT2_ILVLIT2_GLVL; 75 RingTimer--, 29 T2R - 1; 76 } 30 77 else{ 31 //Initialization of various pins 78 Ring active ■ 0; Appendix Appendix 79 RingEnαble - 0, //Stop ringing 126 UartTιmer++, 80 } 127 ♦endif 81 128 82 //This signal generates the 20Hz ring generator signal 129 //Advertising interval 83 ιf(RιngEnable){ 130 i f ( - -advertTιmer«0){ 84 ιf(πngGenTιmer~0){ 131 advertTimer = PH_ADVERT_REL0AD, 85 πngGenTιmer=25, //25ms 132 bc_Advert(), 86 RingPin='RingPin, 133 } 87 } 134 88 else{ 135 89 πngGenTimer--, 136 uchar bc_Advert(){ 90 } 137 /*************** * / 91 } 138 //Assume that the services of the system object are 92 else{ 139 //universally understood 93 RιngPιn»0, 140 Scrιpts[LC_PH_ADVERT] fm scπpt-LC_PH_ADVERT, 94 πngGenTιmer«25, 141 Scripts[LC_PH_ADVERT] msgType-BROADCAST, 95 } 142 Scrιpts[LC_PH_ADVERT] toAddr addr node-0, 96 143 Scrιpts[LC_PH_ADVERT_ toAddr addr scrιpt=0, 97 //This timer is used to re-send to the NIC chip 144 Senpts[LC_PH_ADVERT] payType=SERVICE_ENUM, 98 //is no response is received 145 Scrιpts[lC PF ADVERT] payLen-sιzeof(servStruct), 99 ιf(TxTιmer){ 146 Scπpts[LC_PH_ADVERT] up payPtr=(uchar*)servιces, 100 TxTimer — , 147 101 } 148 T5IC &= -INT.ENABLE, 102 149 postTxQueue(&Scrιpts[LC_PH_ADVERT]), 103 //This timer opens the speech channel so that 150 T5IC I- INT-ENABLE, 104 //DTMF tones can be checked if they are local or 151 105 //remote 152 return 0, 106 ιf(DιsConnectTιmer){ 153 107 DisConnectTimer , 154 108 } 155 109 156 void sm_DtmfDιal(){ 110 ιf(StayAlιveTιmer){ 157 y ******* ********* y 111 StayAliveTimer-- , 158 /* This is a state machine triggered by a command */ 112 } 159 /* event message As such it uses the imfBuff def'd */ 113 160 /* in the ezmcrx module «/ 114 ♦ if DEBUG_0UT '= LCDJHSPLAY 161 static uchar dtmfCounter, 115 //Digital clock 162 116 ιf( -tιmeTιmer~ø){ 163 ♦define GAP_PERIOD DtmfDigitTime 117 tιmeTιmer-1000; 164 118 ιf(++secs«=60){ 165 ιf(DtmfIndex==0) return, /* Idle state */ 119 secs«0, 166 120 clockO, 167 ιf(DtmfIndex«0x80){ 121 } 168 /•Dial 1st digit*/ 122 } 169 DtmfDιgιt=DtmfBuff[0] , 123 ♦endif 170 DtmfIndex - 1, 124 171 dtmfCounter = DtmfDigitTime, 125 ♦ if DEBUG_0UT «=- UART 1 2 } Appendix Appendix 173 else{ 19 ♦include \ioregs h 174 ιf -dtmfCounter— ){ 20 ♦include h 175 /•If digit timer timed out then proceed*/ 21 ♦include h 176 ιf(DtmfDιgιt>0){ 22 ♦include \dbase h 177 /•Setup for inter-digit gap*/ 23 ♦include \zones h 178 DtmfDigit-ø; 24 ♦include \ulaw h 179 dtm Counter=GAP_PERIOD, 25 ♦include \display h 180 } 26 ♦include ' \prior h 181 else{ 27 ♦include \codec h 182 /•Get next digit*/ 28 ♦include \uart h 183 DtmfDιgιt-DtmfBuff[DtmfIndex++], 29 ♦include ph_pιπs h 184 ιf(DtmfDιgιt—0){ 30 ♦include ph-main h 185 /•End of dial*/ 31 ♦include ph_scrpt h 186 DtmfIndex-0; 32 ♦include ph_tιmer h 187 /* Send CmdAck process completed */ 33 188 Scripts[LC_PH_DIALSTR] u . ayData-0, 34 /* Enumerati on of EZNICRX Errors */ 189 Scrιpts[LC_PH.DIALSTR] sgType-RP.ENDED, 35 ♦define ERR PAYLOAD_INVALID_LENGTH 0x8 1 ICRX. ZONE. ID 10x0 190 postTxQueue(8,Scrιpts_LC_PH_DIALSTR_), 36 ♦define ERR. ADDR_N0T_FOUND 0x801 NICRX. ZONE. IDIøxl 191 } 37 ♦define ERRJ NO_ACK_PENDING 0x8 1 ICRX. ZONE. ID 10x2 192 else{ 38 ♦define ERR. ADDRESS-UN NOWN 0x801 ICRX. ZONE. ID 10x3 193 dtmfCounter - DtmfDigitTime, 39 ♦define ERR MAIL_LIST_EMPTY 0x801 NICRX. ZONE. ID 10x4 194 } 40 ♦define ERRJ UNKNOWN_DE_SCRIPT_ADDR 0x801 NICRX. ZONE. ID 10x5 195 } 41 ♦define ERR UNKNOWN_SI_SCRIPT_ADDR 0x801 NICRX. ZONE. ID 10x6 196 42 ♦define ERRJ PAY_TYPE_MISMATCH 0x801 NICRX. ZONE. ID 10x7 197 43 ♦define ERR NONSENSE-MSG 0x801 NICRX. ZONE. IDI0x8 198 44 ♦define ERRJ UNSUPPORTED_FORMAT 0x801 NICRX. ZONE. ID 10x9 45 ♦define ERRJ MSG_TYPE_MISMATCH 0x801 NICRX. ZONE- IDI øxA LISTING phone/ph_scrιpt c 46 ♦define ERRJ PAYDATA.OOB 0x801 NICRX. ZONE. ID I øxB 47 ♦define ERR OWNER_MISMATCH 0x801 NICRX. ZONE. IDIøxC 1 48 ♦define ERR_ DTMF_DIALER_BUSY 0x801 NICRX. ZONE- IDI øxD 2 These are the scripts contained in the NICRX zone 49 3 they are: 50 //increments of 1ms 4 chl_SpchMaιlLιst, 51 ♦define RING_GEN_TIMEOUT 1000 5 chl_de_Rmg0n0ff , 52 6 chl_HookReceptor, 53 static address Owner , 7 chl_DιalDιgιtTιme, 54 /• 8 chl_DιalMode, 55 The RxQueue scheme implemented here could have been simplified given 9 ch2_DtalStr, 56 that only 2 buffers are employed However a full rotating buufer 10 chl_AppIπtf, 57 scheme was implemented so that experiment with 3,4 etc buffers 1 1 pp_CιdDecode 58 could readily be tried 1 2 */ 59 •/ 1 3 60 ♦define RING ANS_TIMEOUT 1000 14 ♦include <regl61 h> 61 1 5 ♦include <ιntrpdef h> 62 ♦if TEST i-0 1 6 ♦include <ιntrιns h> 63 uchar RxBuffA[MAX_PKT_SIZE] , 17 ♦include ' \defs h" 64 uchar RxBuffB[MAX_PKT_SIZE] , 18 ♦include \globals h 65 ♦else Appendix Appendix static uchar RxBuffA[MAX_PKT_SIZE] ; 113 Comment static uchar RxBuffB[MAX_PKT_SIZE] ; 114 ♦endif 115 Only ULAWJΞNCODED currently supported 116 */ uint temp, address target; ♦ if DEBUG_OUT—UART static const uchar fName[ - "chl_SpchMaιUιst"; ♦endif imfPtr >fm script - LC_PH_SPCHMAILLIST, ♦ifdef BLOB //Check Owner ιf(ιmfPtr->toAddr.addr. ode l» Owner.node){ ♦if DEBUG_OUT—UART putsUart2('\rErr: <0 NER> mismatch in ",fName); ♦endif return ERR_OHNER_MISMATCH, } ♦endif swιtch(*msg++){ //switch on <msgType> case RP-SPAWN: /* */ //PayType ιf(*msg++ '= UNSIGNED_CHAR){ ♦if DEBUG.OUT—UART putsUart2('\rErr- <PAY_TYPE> mismatch in ,fName), ♦endif return ERR_PAY_TYPE_MISMATCH, } ♦define PAY.LEN temp PAY_LEN=*msg++, //Extract the target address target node=*msg++; target scrιpt»*msg++; swιtch(PAY_LEN){ //This is a switch on <PAY_LEN> case 3 /*---*/ //Turn off the stream various errors 158 1 f(*msg==SPCH_FLOW_OFF){ 159 Appendix Appendix Y_LEN> in ", fName); NGTH; atch in ",fName); uct* tmfPtr){ replicate the ring function also "re-primes" etermines whether or not " state This state s to al struct RingStruct. Appendix Appendix Appendix Appendix 395 ♦if DEBUG_OUT«UART 349 ιmfPtr->fm. script - PR-H00KRECEPT0R; 396 putsUart2("\rErr: <MSG_TYPE> mismatch in ",fName); 350 397 ♦endif 351 switch(*msg++){ //switch on <MSGTYPE> 398 return ERR_MSG_TYPE_MISMATCH; 352 case RP_SPA N: 399 } 353 / . . / 400 return 0, 354 //<PAY_TYPE> 401 355 if(*msg++ I- UNSIGNED_CHAR){ 402 356 ♦if DEBUG_0UT— UART 403 uchar chlJjιalDigitTime(uchar* msg, imfStruct* imfPtr). 404 /♦•A***********************************************,,,** 357 putsUart2("\rErr: <PAY_TYPE> mismatch in " , fName) 358 ♦endif 405 /* 359 return ERR_PAY_TYPE_MISMATCH; 406 Syntax: 360 } 407 361 408 msgType: RP_SPAWN 362 payLen=*msg++; 409 363 if(payLen l){ 410 payType: UNSIGNED.CHAR 364 ♦if DEBUG_0UT— UART 411 365 putsUart2("\rErr: Invalid <PAYLEN> in " , fName); 412 payLen : 1 366 ♦endif 413 367 return ERR PAYLOAD_INVALID_LENGTH; 414 payLoad: DigitTi e in 10s millisecs 368 } 415 369 416 returns: 0 success 370 //Get the data 417 various errors 371 switch(*msg){ 418 372 case 0: 419 Comment 373 / . */ 420 374 RemoteHook. active - 0; 421 Digit time must be greater than 50ms and less than 255ms 375 break; 422 */ 376 423 uint dt; 377 case 1: 424 ♦if DEBUG_OUT==UART 378 425 const uchar fName[] - "chlJ ialDigitTime" ; 379 RemoteHook. active - 1; 426 ♦endif 380 break; 427 381 428 imfPtr->fm script = LC_PH_DIALDIGITTIME ; 382 default: 429 383 /* */ 430 //Check Owner 384 return ERR_PAYDATA_00B; 431 if(imfPtr->toAddr. addr. node !» Owner. node){ 385 } 432 ♦ if DEBUG_OUT«UART 386 433 putsUart2("\rErr: <0WNER> mismatch in " , fName); 387 //Update other state within the "remoteStruct" . 434 ♦endif 388 RemoteHook. node - imf Ptr->toAddr. addr. node; 435 return ERR_O NER_MISMATCH; 389 RemoteHook. script- imfPtr->toAddr. addr. script; 436 } 390 RemoteHook. msgType = imfPtr->msgType; 437 391 break; 438 switch(*msg++){ //switch on <msgType> 392 439 case RP_SPAWN: 393 default: 440 /* */ 394 /* */ 441 //PayType Appendix Appendix Appendix Appendix Appendix Appendix 10 return ERR_PAYDATA_00B , 677 script being exec 'd !1 } 678 12 679 */ 13 *(DtmfBuff+ι ø /* Termi nating zero 680 14 Dtmflndex=0x80 , /* Set start dial bit 681 ♦ if DEBUG J)UT==UART 15 } 682 const uchar fNameD - chl_AppIntf , 16 else{ 683 ♦endif 17 ♦if DEBUG_OUT=-UART 684 uint payLen , i , 18 putsUart2( \rErr Dial busy in ,fName), 685 uchar* payPtr , 19 ♦endif 686 \0 return ERR_DTMF_DIALER_BUSY, 687 imfPtr >fm script = PH_APPINTF , 11 } 688 12 } 689 swιtch(*msg++){ //switch on <msgType> 13 break, 690 case RP_ENDED 14 691 /* . / 15 default 692 Scπpts[PH APPINTF] rpEnded=l, 16 /* -*/ 693 Scπpts[PH_APPINTF] payType-*msg++ , 17 ♦if DEBUG_0UT—UART 694 Scrιpts[PH_APPINTF] payLen-payLen-*msg++, 18 putsUart2( VErr <MSG_TYPE> mismatch in , fName), 695 swιtch(paylen){ 19 ♦endif 696 case 0 .0 return ERR_MSG_TYPE_MISMATCH, 697 / ♦ */ l l } 698 break , .2 return 699 .3 700 case 1 ι4 701 /* •/ ι5 uchar chl_AppIntf(uchar* msg, imfStruct* ιmfPtr){ 702 Scπpts[PH_APPINTF] up payData=*msg, .6 /*********** **********+*+****+******************** / 703 break , 7 704 Syntax 705 default 9 706 /*- */ l0 msgType RP_ENDED 707 1-0, l l 708 payPtr = Scπpts[PH_APPINTF] up payPtr, .2 payType ANY 709 whιle(κpayLen){ .3 710 *(payPtr+ι)=*msg++, »4 payLen ANY 71 1 1 ++ , .5 71 2 } .6 payLoad ANY 71 3 } ι7 714 break, »8 returns ø (always) 71 5 •9 71 6 default 0 Comment 717 /*- ♦ / ' 1 71 8 ♦if DEBUG_OUT==UART '2 Interface script to the phone application Copies 719 putsUart2( VErr <MSG_TYPE> mismatch in , fName) '3 salient parts of the message from the RxDBuff to 720 ♦endif '4 this script's imfStruct" 721 return ERR MSG TYPE_MISMATCH, • 5 IMPORTANT If a string is expected for the payData 722 } '6 the up payPtr must be initialized prior to this 723 return 0, Appendix Appendix } 771 772 char getTιme(uchar* msg){ /•*•* * •**•••******•*****»***•*•*•**********•**«*«««•*••• * ****.»»***** / 773 /******* * ** • ****** • ***** /* Data Event Receptor Scripts •/ 774 const char xhuge • ptr; / •*** * •*• * *•***•**** * ••******•*•**••*•*********•**•*•*****«*•***.**•• / 775 uchar c, 776 777 ιf((*msg >'0' ){ This is the CID parser and display formatter. It is 778 c-0; envoked when a CID msg arrives from a CID service unit. 779 } 780 else{ The local clock is running under a timer, This is updated 781 ι ((*msg)— l '){ by the caller ID service every time a msg is rx'd. 782 c-10; 783 } 784 else{ 785 return -1, typedef struct { 786 } char month[3]; 787 } char day[2]; 788 msg++; char hour[2]; 789 ιf((*msg>-'0' )-,S(*msg<-'9')){ char mιn[2]; 790 c+- *msg- '0' , }tιmeStruct; 791 } timeStruct Time - {'J'.'a'.'n'.'l'.'ø'.'Z'.'l'.'ø'.'ø'}; 792 else{ 793 return -1, const char months[] - "JanFebMarAprMayJunJlyAugSepOctNovDec"; 794 } 795 msg++; void clock(){ 796 c--; //make Jan-=0 not 1 /*****»*♦***/ 797 tf(c>.12){ ιf(++Tιme.mιn[0]>'9'){ 798 return -1; Tιme.mιn[0]-'0' ; 799 } ι f(++Tιme.mιn[l]—'6'){ 800 ptr«_months[c*3]; Time mιn[lT-'0' ; 801 Tιme.month[0]-*ptr++, ++Tιme. hour[0] ; 802 Time month[l]«*ptr++; if ((Time hour[l]— '2 , )&&(Tιme. hourrø]— '4')){ 803 Time month[2]=*ptr; Time hour[0_-'0' ; 804 Time hour[l]-'0' ; 805 Time day[l] - *msg++; } 806 Time. day[0] - *msg++, else{ 807 ιf((Tιme.hour[l]--'l , )&&(Tιme.hour[0]>'9' )){ 808 Time. hour [1] - *msg++; Tιme.hour[0]-'0' ; 809 Time. hour [0] - *msg++; Tιme.hour[l]-' l' ; 810 } 81 1 Time mιn[l] - *msg++; } 812 Time mιn[0] - *msg++; } 813 } 814 return 0; pπntTimeO; 815 } 816 817 void prιntTιme(){ Appendix Appendix Appendix Appendix the modem signals to any ataached equip. 959 ♦ if DEBUG-.0UT--UART CID(msg); 960 putsUart("\rDrop thro' in cιdDecode()"); 961 ♦endif is point "msg" points to <FMSCRIPT> 962 break; RIPTxMSGTYPExPAYTYPExPAYLENxPAY ..> 963 } 3; //Skip first 3 fields. 964 } 965 } >fm.script = PH_CIDDEC0DE ; 966 else{ 967 //SDMF format he format, SDMF or MDMF 968 ιf(getTιme(msg) !«0){ 969 //ret 0 even though error occurr because 9-1; ++—SDMF){ 970 //can't do anything to correct. fFlag=0, 971 return 0; 972 } 973 pπntTimeO ; he msg length. 974 msg+-8; rather odd looking expr computes the 975 getNumber(msg) ; ng address" of the data 976 putsEL(m3); ,g + *msg; 977 } 978 return 0; 979 } ' data 'Flag){ L LISTING phone/ph_sm_pt h ιle(msg<eom){ swιtch(*msg++){ 1 void smPlaySιngleTrack(uchar track, phStatePtr retState) case 1: //Time 2 void smSeqPlay(phStatePtr retState), /*---*/ 3 void ptWaιtForTrack(); paramLen-*msg++; 4 void imtTracksO ; getTιme(msg), 5 break; 6 ♦ if DEBUG-.0UT— UART 7 void lιstTracks() ; case 2 //Number 8 ♦endif case 4 //Absence of number 9 /*---*/ 10 extern playStruct Play; paramLen«*msg++; 1 1 extern uchar SeqTrk[] ; getNumber( sg); 12 extern bit SpchSeqActive; break, 1 3 enum{ 14 ZER0-1 , case 7. //Name 1 5 ONE , case 8' //Absence of name 1 6 TWO , /*---*/ 17 THREE , paramLen-*msg++; 18 FOUR , getName(msg , paramLen) ; 19 FIVE , break, 20 SIX , 21 SEVEN , default : 22 EIGHT, / . . / 23 NINE , Appendix TEN, 71 <PICKUP> ELEVEN, 72 Too late , another extention has picked up the call . TWELVE, 73 BING, 74 <AND> NO_ANS, 75 and INVALID, 76 LCBUSY, 77 <UNKNOWN_DEVICES> PH_BUSY, 78 other devices PROBLEM, 79 PICKUP, 80 <A_PH0NE> AND, 81 phone NEW-CONNECT, 82 ADDED-TO_SYSTEM, 83 <PH0NES> A_NEW, 84 phones INV_INTRO, 85 UNKNOWN_DEVICES, 86 <A_LINECARD,> A_PHONE , 87 line card PHONES, 88 A_LINECARD, 89 <LINECARDS> LINECARDS, 90 line cards A.COMPUTER , 91 COMPUTERS, 92 <A.COMPUTER,> A.PRINTER, 93 conputer PRINTERS, 94 OVERLAP, 95 <COMPUTERS> NUMBER_TRACKS 96 computers }; 97 98 <A_PRINTER> ♦define SEQ_END øxFF 99 printer 100 /* 101 <PRINTERS> Script for the tracks 102 printers <NO_ANS,> 103 There is no answer at that extension 104 <INV_INTR0> 105 The following products are connected to thp÷s network <INVALID,> 106 That extention number is invalid 107 <NEW_CONNECT> 108 "This unit has been successfully assimilated into the network <LC_BUSY> 109 In addition to this unit the network contains:" I'm sorry all outside lines are busy. 1 10 1 1 1 <ADDED_TO_SYSTEM> <PH-BUSY> 1 1 2 has been added to the system " I'm sorry that extention is busy 1 1 3 1 14 <A_NEW> <PR0BLEM> 1 1 5 ' a new" There seems to be a problem with that extention. 1 16 1 17 Appendix Appendix the database s to the node ♦ Appendix Appendix 74 dblndex-0, 121 GpRetValue-GP_USER_EXIT, 75 do{ 122 PhPtr-gpRetState, 76 dblndex - dbSeαrchServιce(dbIndex,&ss) , 123 77 124 } 78 ιf(dblπdex — N0T_F0UND){ 1 25 79 GpRetVαlue-GP_N0T_F0UND , 1 26 //Check for the arrival of the offHook msg 80 PhPtr-gpRetStαte, 127 //before sending any further ring msgs 81 return, 128 if(RemoteHook active). 82 } 1 29 /*« EXIT PT »•/ 83 130 //Note that GpRetValue - Dialed Number 84 ιf(ss αddr node—PHN_NUM){ 1 31 DtmfDιgιt-0, 85 break, 1 32 PhPtr-gpRetState, 86 } 1 33 } 87 134 88 //Resume searching from next location in database 1 35 ιf(RιngTιmer==0){ 89 dblndex++, 1 36 CodecTxContro GEN-rjTMF, 90 }whιle(l), 1 37 //Reset the timer 91 1 38 RιngTιmer=RING_TIMEOUT, 92 //OK found the extention now send a rmcj signal 1 39 ιf(rιngSense){ 93 RemoteHook actιve-0, 140 πngSense=0, 94 rιngSense-0, 141 DtmfDιgιt=0, //Turns OFF ring in earpiece 95 RιngTιmer-0; 142 } 96 PhPtr=gpRpsRιngPhone, 143 else{ 97 144 πngSense=l , 98 145 DtmfDιgιt= R', / Turns ON ring in earpiece 99 146 } 00 147 //And send out the ring msg 01 1 48 ιnιtScπpts(ss addr πode.PH-RINGONOFF), 02 void gpRpsRιngPhone(){ 149 //Set up the params 03 / *************** * *** / 1 50 Scrιpts[PH_APPINTF] payLen=l, 04 /* 1 51 Scrιpts[PH_APPINTF] up payData-(uchar)πngSense, 05 There are 2 possible returns from the remote phone in this state 152 postTxQueue(&Scrιpts[PH_APPINTF]), 06 ♦1 The RPE from the ring signal, 1 53 PhPtr gpRpeRingPhone, 07 ♦2 The offHook message cast as an RPS 1 54 } 08 This script is only directly aware of the RPE to its message 1 55 09 However the HookReceptor script sets state that is tested by 1 56 10 this script to determine if it should advance 1 57 void gpRpeRmgPhoneO. 1 1 */ 1 58 /* *** • **** * **********/ 12 static bit seqFlag, 1 59 1 3 1 60 ♦ifdef SM_TRACE 14 ♦ifdef SM_TRACE 1 61 dιsplayState( gpRpeRingPhone ), 1 5 dιsplayState( gpRpsRingPhone ), 1 62 ♦endif 16 ♦endif 1 63 17 1 64 ιf(PhnAppTιmer-==ø){ 18 ιf(DtmfIn active). 1 65 //Node not responding, note the problem 19 Dtmfln actιve-0, 1 66 //and move on 20 i f(DtmfIn digit--STAR_KEY){ 167 goto LblErrorRecover, Appendix Appendix oiO'- r-c\jrvj ωmθ 4 - N msr- i») N-3mθ 4 -wm 4 fuιωs∞oιθ 4 - N m s r-i ( D comθ- ( j m*i Λ ipsraoιθ'-rιmsf ωω NNNNNNNNNN _ ( DooooωcoωcoiDoom-ισιoισι-ιoιmoισ ) θθθθθθθθθθ,-r-r-^ -- 35 uchαr locαlDtmfO, LISTING phone/ph_maιn c 36 void recιteContent(uchαr initTrαck); 37 char sendMsgInLιne(uchar toNode, uchar toScrιpt,\ 1 ♦include <regl61 h> 38 uchar rxScπpt, uchar data), 2 ♦include <ιntrpdef h> 39 uchar connectO, 3 40 void stayA veO, 4 ♦include \defs h 41 5 ♦include \globals h 42 void phConfCallAddStartO, 6 ♦include \ioregs h 43 void phConfCallAddStart_l(); 7 ♦include \mctx h 44 void phConfCallAddStart_2(); 8 ♦include h 45 void phConfCallAddStart.3(), 9 ♦include \zones h 46 void phConfCallAddEndO, 10 ♦include \dbase h 47 void phControlModeO, 11 ♦include \ulaw h 48 void phGetFirstKeyO, 12 ♦include \display h 49 void phGetlmtiaUineO, 13 ♦include \codec h 50 void phGetSecondKeyO, 14 ♦include \pπor h 51 void phGetSecondKey_l(), 15 ♦include \spch h 52 void phldleO , 16 53 void phldle_l() , 17 ♦if DEBUG_0UT==UART 54 void phldle_2() , 18 ♦include \uart h 55 void phRpeAnsPhoneO, 19 ♦include \strutils h 56 void phRpeAnsPsn(), 20 ♦endif 57 void phRpeExitO, 21 58 void phRpeRelLineO, 22 ♦include \psn\lc scrpt h 59 void phRpsAnsPhone(), 23 60 void phRpsAnsPsnO, 24 ♦include ph_pιns h 61 void phRpsExit(), 25 ♦include ph_maιn h 62 void phRpsRelLineO, 26 ♦include ph_scrpt h 63 void phSteadyStateO, 27 ♦include ph_tιmer h 64 void phWaitOπAnnouncementO, 28 65 ββ /***********************/ 29 ♦include ph_sm gl 30 ♦include ph_sm gp 67 /* Globals •/ 31 ♦include ph_sm_pt « »****.****....*****•*•• 32 ♦include ph_sm_sc 69 extern uchar CodecTxControl, 33 ♦include ph_sm_ss 70 extern uchar AppBuff[4] , 34 71 extern phStatePtr PhPtr, 35 ♦define C0MB0.DTMF 0x02 36 ♦define COMBCCID 0x04 37 ♦define C0MB0_0N_H00K øxøβ 38 ♦define COMBO OFF_HO0K 0x10 39 ♦define C0MB0-.PRINT 0x20 40 ♦define C0MBO-DTMF_VALID 0x40 41 //All of these times are in millisecs 42 ♦define APP_TIME0UT 200 43 ♦define STAY_ALIVE_INTERVAL 100 44 45 ♦define SUBSCRIBE 1 Appendix Appendix 93 static servStruct ss; ♦define RADIUS 2 94 95 /** •• ** * *** « / 96 /* Globals */ If α cell fails to respond to a data event (ie no ack received within 97 / . **********/ a certain time interval) then that device should be removed from the 98 uchar CodecTxControl; database and mai ling lists of any services with self 99 ♦define PROBLEM_SIZE 4 */ 100 static uchar problemNodeArray[PROBLEM_SIZE_; 101 static uchar proble lndex; /* * * ******* **.*« **** * * */ 102 void logProblem(uchar node){ /* Inter-Zone buffers */ 103 /****♦****.*******♦♦***♦•**/ /****♦**♦**.***********/ 104 //Scan to see if this is already known about bit LocalHookState, 105 uint i; bit AULinesBusy; 106 for(ι-0, κproblemIndex, l++){ bit PsnAdded; //This is set of the LAST (newest) member added was a PSN 107 i f(problemNodeArray[i_==node){ bit CodecSinkFlag.CodecSrcFlag; 108 return, 109 } imfStruct Scπpts[PH-T0TAL_SCRIPTS] ; 1 10 } re oteState Ring, RemoteHook; 1 1 1 //If not know then log - if space provides dtmfStruct Dtmfln; 1 12 if(problemlndex < (PR0BLEM.SIZE-1)){ uchar DtmfBuff[16] , 1 13 problemNodeArray[problemIndex++]-node; uchar DtmfDigitTime * (uchar)((ιnt)100/(ιnt)TIMER2_PERI0D); 1 14 } uchar Dtmflndex, DialMode; 1 1 5 } uchar Dt fDigit; 1 16 uchar SelfAddr; 1 17 uchar StayAliveTimer, 1 18 void comboO interrupt EXT3{ uint RingTimer.DisConnectTimer; 1 19 /»******************♦♦****•/ //Setup the Inventory Timer with a "long" 1 20 uchar c; //initial period to ensure we get the database updated 1 21 ♦if DEBUG_OUT==UART uint InventoryTimer - 4000; 1 22 uchar str[4] , 1 23 ♦endif /** *« ************ * / 1 24 c-StatusReg&øxFF; /* Mailing Lists */ 1 25 lf(c8,C0MB0_DTMF){ /********** • * » ****/ 1 26 Dtmfln actιve=l; mailAddr spchMaιlLιst[SPOθωiL_LIST_SIZE] ; 127 Dtmfln dιgιt-DtmfReg«40xF; mailStruct SpchMaιlStruct«{spchMaιlLιst,0,SPCH_MAIL_LIST_SIZE} ; 1 28 //Simple mapping of zero. 1 29 if(DtmfIn digit—0xA){ /** • *************•/ 130 Dtmfln dιgιt=0, /* Local Globals */ 131 } /*••****♦*********/ 132 uint PhnAppTimer; 133 ♦if DEBUG_0UT== -ART uchar AppBuff[4] ; 134 formatHexUchar(str, Dtm In. digit); phStatePtr PhPtr ; 135 putsUart2("\rDtmf digit - 0x" ,str); 1 36 ♦endif static uchar reSendCount; 1 37 static uchar smsIndex.smsNode; 138 static uchar dblndex.phnNum; 1 39 lf(c8.C0MB0_0FF_H00K){ Appendix Appendix ie TSD_PHN etc) Appendix Appendix 234 ιf(CodecPostFlαg){ 281 / . » / 235 //! < ! PUT 4MONITOR HERE I I ! 282 connectO; 236 //For tetsmg include the line below. 283 ♦ if DEBUG-.0UT— UART 237 //♦include "sιg_gen c" 284 listTracksO; 238 CodecPostFlαg=0; 285 putsUart("\rCopyrιght IQ Systems, Inc. 1998") ; 239 T2IC 8,- -INT_ENABLE; 286 putsUart( \rPhone Interface rev 0.24"); 240 T5IC &- -INT.ENABLE; 287 ♦endif 241 postTxQueue(8ιScrιpts[LC_PH_SPCHPKri); 288 DbEπtπes - totalEntπes; 242 T5IC I- INT_ENABLE; 289 topState»0N_H00K, 243 T2IC l» INT-ENABLE; 290 InventoryTιmer-INVENTORY_INTERVAL; 244 } 291 break, 245 292 246 nicTxDispO, 293 case 0N_H00K- 247 294 / . . / 248 ιf((PπvαteFlαg—l)&8.(SpchMαιIStruct. eol—l)&S(PsnAdded—l)){ 295 ιf(InventoryTιmer—>0){ 249 //Send 'stay alive" msgs to the PSN. 296 InventoryTιmer-INVENT0RY_INTERVAL, 250 //This is also the hook to sending music in the future. 297 ιf(DbEntrιes < totalEntπes){ 251 //Use the RINGONOFF Scπpts[6] imfStruct for this as it can't 298 /• 252 //possibly be used when the phone is in an off hook state 299 A new cell(s) has been added to the system 253 1f(StayAl1veTi er—0){ 300 1 if approp subscribe to mailing lists 254 stayAliveO; 301 2. announce this. 255 } 302 Comment here of the form: 256 303 <A new> <phone> <has been added to the system> 257 304 */ 258 ♦if DEBUG-.0UT- ■UART 305 connectO; 259 tickleUartO, 306 260 ♦endif 307 //Loop is there for the case when more than one 261 308 //device is added simultaneously. 262 swιtch(topState){ 309 SeqTrk[0]-A_NEW; 263 case SPK_INV: 310 SeqTrk[l]-(2*dbase[DbEntrιes] dbs servιce)+A_PH0NE; 264 /*—- -*/ 31 1 SeqTrk[2]=ADDED_T0_SYSTEM, 265 //Recite what can be seen. 31 2 SeqTrk[ 3 ]=SEQ_END, 266 AmpEnablePιn-0; //Amp ON 31 3 267 re iteContent(NEW_C0NNECT); 314 //Sentance compiled - send to the player 268 topState-WAIT_SPK_INV; 31 5 AmpEnablePin-0, //Amp ON 269 //Having spoken the itinery update local param. 316 smSeqPlay(PhPtr); 270 break; 317 topState-0N_H00K_SP ; 271 318 } 272 case WAIT_SPK_INV 319 //This facilitates the shrinking of the 273 / . . / 320 //database when a node is removed as well as 274 1f(SpchSeqActive—0){ 321 //update if code above exec'd 275 topState-EST.CONNECT; 322 DbEntπes = totalEntπes, 276 PhPtr-phldle; 323 } 277 } 324 else{ 278 break; 325 //This is the "normal" code for this state 279 326 //ie idle awaiting off hook. 280 case EST_C0NNECT. 327 CodecSrcFlag«CodecSιnkFlag-ø; Appendix Appendix 328 CodecTxControl-STD.CALL ; 375 / The "StayAliveTimer" is used to determine when to 329 ιf(LocαlHookStαte— 1){ 376 //send another re-prime the watchdog msg. 330 topStαte-OFF.HOOK; 377 331 RιngEnαble=0; 378 StayAlιveTιmer=STAY_ALIVE_INTERVAL; 332 } 379 333 } 380 Scπpts[PH ^ RING0N0FF] .msgType-RP.SPAWN, 334 break; 381 Scπpts[PH_RING0N0FF] fm node-Self Addr; 335 382 Scrιpts[PH_RING0N0FF] . fm. scπpt-PH_RING0N0FF; 336 case 0N_HOOK_SPK: 383 Scπpts[PH_RING0N0FF] toAddr. addr. node-spchMaιlLιst[0] . addr. node; 337 / . */ 384 Scrιpts[PH_RING0N0FF] toAddr. addr. scrιpt=LC-.LINESEIZE; 338 //This is a "holding state" awaiting the end of 385 Scπpts[PHJUNG0N0FF] payType=UNSIGNED_CHAR; 339 //the end of the new deviced added announcement 386 Scrιpts[PH„RING0N0FF] payLen-1; 340 ιf(SpchSeqActιve— 0){ 387 Scrιpts[PH_RING0N0FF] up payData=2; //Refresh the watchdog. 341 topState-0N_H00K; 388 342 } 389 T2IC &= ~INT_ENABLE ; 343 break; 390 T5IC &= ~INT_ENABLE ; 344 391 345 case 0FF_HOOK: 392 postTxQueue(8,$cπpts[PH_RING0N0FFj); 346 /* */ 393 347 ιf(LocalHookState— 0){ 394 T5IC I- INT_ENABLE; 348 smslndex=ø; 395 T2IC 1= INT_ENABLE; 349 reSendCount-0; 396 } 350 PhPtr=phRpsExιt; 397 351 topState-TEAR_D0WN; 398 uchar connect(){ 352 / * * * *** ***** • **/ } 399 353 break; 400 /• 05/29/9809-12 am 354 401 Attaches to any PSNs that are with a distance of 355 case TEAR_D0WN: 402 RADIUS from SelfAddr. 356 / . . / 403 */ 357 ιf(PhPtr—phIdle){ 404 uchar distance ,mc,numberConnects,node; 358 topState=0N_H00K; 405 uchar str[4]; 359 } 406 numberConnects=0; 360 break ; 407 for(mc=DbEntπes;mc<totalEntrιes;mc++){ 361 408 node=dbase[mc].dbs.addr node; 362 } 409 dιstance=node>SelfAddr'node-SelfAddr:SelfAddr-node; 363 410 ιf(dιstance<=RADIUS){ 364 //H I DEBUG 41 1 sendMsgInLιne(dbase[mc].dbs.addr.node,LC_RINGMAILLIST,\ 365 ιf(PhPtr>0x7FFF){ 412 PH_RING0N0FF ,SUBSCRIBE); 366 //Pt to catch a wild ptr. 41 3 sendMsgInLιne(dbase[mc].dbs.addr.node,LC_CIDMAILLIST,\ 367 PhPtr-phldle; 414 PH_CIDDEC0DE ,SUBSCRIBE) ; 368 } 41 5 numberConnects++; 369 416 ♦if DEBUG_0UT—UART 370 (*PhPtr)() ; 417 formatHexUchar(str,node); 371 } 418 putsUart2("\rAttached to node: ",str); 372 } 419 ♦endif 373 void stayAlιve(){ 420 } 374 /** . * • * •••» *****/ 421 } Appendix Appendix 422 return numberConnects; 469 // numbers' tracks 423 470 i f (devCount [mc]— 1){ 424 471 //Use the single case 425 void recιteContent(uchαr ιnιtTrαck){ 472 SeqTrk[2*mc+2]-2*mc+A_PH0NE ; 426 ** • ***** . * • ******* » ** . ** .. ** . ** • **/ 473 } 427 /* Compile an inventory of devices - for the time 474 else . 428 being assume that the net comprises only 475 //Use the plural 429 STD_PSN 476 SeqTrk[2*mc+2]-2*mc+A_PH0NE+l; 430 STD_PHN 477 } 431 COMPUTER 478 } 432 PRINTER 479 SeqTrk[2*mc+l]=AND, 433 */ 480 SeqTrk [2*mc+2]=devCouπt [mc]+ZER0 , 434 uchar mc,md, 481 SeqTrk[2*mc+3]=UNKN0WN_DEVICES, 435 uchar devCount[TOTAL_DEVICES]; 482 SeqTrk[2*mc+4]-SEQ_END; 436 483 //Sentance compiled - send to the player 437 for(mc-0;mc<TOTAL_DEVICES;mc++){ 484 smSeqPlay(PhPtr) , 438 devCount[mc]=0, 485 439 } 486 440 487 void ιnιtScπpts(uchar toNode, uchar toScrιpt){ 441 /* 488 /**• ** . ******** . ** .. ** **. **** ..* ** » * * **•**** * • / 442 The following logic constructs a sentence of the 489 //Args are the target node/script 443 this form 490 Scπpts[PH_APPINTF] msgType-RP.SPAWN, 444 491 Scrιpts[PH_APPINTF] rpEnded=\ 445 492 Scrιpts[PH-APPINTF] rpStartedA 446 This unit has been successfully assimilated into the network 493 Scrιpts[PH_APPINTF] rpError=0, 447 The network contains: 494 Scrιpts[PH_APPINTF] fm node-SelfAddr, 448 Three phones 495 Scrιpts[PH_APPINTF] fm scπpt=PH_APPINTF; 449 Two linecards 496 Scrιpts[PH_APPINTF] toAddr addr node-toNode; 450 Zero computers 497 Scrιpts[PH_APPINTF] toAddr addr.script-toScπpt; 451 Zero printers 498 Scrιpts[PH_APPINTF] payType=UNSIGNED_CHAR; 452 and 499 453 Zero unknown devices 500 PhnAppTιmer-APP_TIMEOUT, 454 501 } 455 •/ 502 456 for(mc-0,mc<totalEntries;mc++){ 503 char sendMsgInlιne(uchar toNode, uchar toScrιpt,\ 457 md-dbase[mc] .dbs.service; 504 uchar rxScπpt, uchar data){ 458 if((md>-STD_PSN)_&(md<PRINTER)){ 505 /***.♦*•»»..*.»•*•*•»****»**.**»•♦♦♦**.*♦***♦*♦»* 459 devCount [dbase [mc] dbs servιce]++; 506 uint retries , 460 } 507 461 else{ 508 Scπpts[PH. APPINTF] msgType=RP_SPAWN, 462 devCount[TOTAL_DEVICES-l]++; 509 Scrιpts[PH. APPINTF] rpEnded-\ 463 } 510 Scrιpts[PH. APPINTF] rpStarted-\ 464 } 51 1 Scrιpts[PH. APPINTF] rpError=ø; 465 512 Scripts [PH. APPINTF] fm node-Self Addr; 466 SeqTrk[0]-ιnιtTrack; 513 Scrιpts[PH. APPINTF] fm.scrιpt-PH_APPINTF; 467 for(mc-0,mc<TOTAL_DEVICES-l;mc++){ 514 Scπpts[PH. APPINTF] toAddr addr node-toNode; 468 SeqTrk[2*mc+l]-devCount[mc]+ZER0; //ZERO is the offset in the 51 5 Scrιpts[PH. .APPINTF] toAddr addr script-toScπpt, Appendix Appendix 516 Scripts [PH_APPINTF] . αyType-UNSIGNED_CHA ; 563 517 Scπpts[PH_APPINTF] .pαyLen-3; 564 518 AppBuf f[0]-Self Addr; 565 519 AppBuf f[l]-rxScrι pt ; 566 ♦define PSN_NODE-NUM GlRetValue 520 AppBuf f[2]»dαtα; 567 void phldle(){ 521 Scπ ts[PH_APPINTF] up pαyPtr-AppBuff; 568 / » * . *********/ 522 retries=0; 569 / ♦ 523 LblSendMsg: 570 This state is only responsible for lauchmg the 524 postTxQueue(_Scrιpts[PH_APPINTF]); 571 approp state machine The tear down process is 525 //Note the explicit call to the transmitter 572 monitored in maιn() 526 nicTxDispO; 573 */ 527 574 ♦ifdef SM_TRACE 528 PhnAppTιmer=APP_TIMEOUT; 575 displayStateC Vphldle"); 529 whιle(Scrιpts[PH_APPINTF] rpEnded—0){ 576 ♦endif 530 lf(PhnAppTimer—0){ 577 531 if(retries—RESEND_LIMIT){ 578 ιf(LocalHookState—1){ 532 //Abandon action and move on. 579 CodecStnkFlag»l; //I want to hear something 533 //!''Need a reporting mechanism 580 //when the phone is off hook. 534 return -1; 581 535 } 582 SpchMai IStruct eol-0; 536 else{ 583 537 retrιes++; 584 if (Rin . actιve~l){ 538 goto LblSendMsg; 585 CodecTxContro STD.CALL ; 539 } 586 DtmfDιgιt»0; 540 } 587 i f (R i ng . msgType—DATA_EVENT) { 541 } 588 PhPtr=phRpsAnsPsn , 542 return 0; 589 } 543 590 else{ 544 591 i f (Ri ng . msgType— RP-.SPAWN) { 545 592 PhPtr-phRpsAnsPhone; 546 uchar localDtmf(){ 593 } 547 /* * « * • ** ** * • * «•**/ 594 } 548 /* 04/09/980901 am 595 } 549 Disconnects hybrid loop to check if the Dtmf tones 596 else{ 550 being received is local or not 597 //Immediately get a outside line. 551 */ 598 //This SM returns 0 for success, 1 for 552 599 //all lines busy. 553 CodecSinkFlag=0; //Will cause zeros to be sent to codec. 600 smGetLine(phldle_l); 554 PhnAppTimer-løø; //100ms wait. 601 } 555 while(PhnAppTιmer); 602 } 556 ιf(StatusReg & COMBO_DTMF.VALID){ 603 } 557 //If still valid then locally generated. 604 558 CodecSιnkFlag=l; 605 void phldle-l(){ 559 return 1; 606 /* .. *** • * *• •** •/ 560 } 607 ♦ifdef SM_TRACE 561 CodecSιnkFlag-1; 608 displayStateC \rphldle_l"); 562 return 0; 609 ♦endif Appendix Appendix 657 ιf(GlRetVαlue— GL_ALL_LINES_BUSY){ 658 } AllLιnesBusy-1; 659 PhPtr=phGetFι rstKey , 660 void phGetFιrstKey(){ 661 /*. ****** * * *•* *** * ** / } else{ 662 ♦ifdef SM.TRACE //Connect to this outside line on α 663 dιsplayState( XrphGetFirstKey ), //temp basis for now 664 ♦endif AllLιnesBusy-0, 665 smlmtConnect(PSN_N0DE_NUM,phldle_2), 666 //If user is wanting to make an outside call but } 667 //all lines were busy then he will remain in this 668 //state unless a ♦ is pressed or the phone goes 669 //on hook void phldle_2(){ 670 ************** / 671 //Provide locally generated dial tone 672 DtmfDιgιt-'T', Error Sceneπo 673 CodecTxControl-GEN_DTMF, To get an error at this stage would require that the 674 already discovered PSN that has seized an outside line 675 ιf(DtmfIn active—1){ suddenly stopped responding - unlikely So in the rare 676 DtmfDιgιt-0, //Turn off dial tone once key pressed event that this happened the action here is to report 677 Dtmfln actιve-0, the problem and see if another PSN is free 678 PsnAdded=0, //default to cleared */ 679 ιf(DtmfIn dιgιt-=P0UND_KEY){ ♦ifdef SM-TRACE 680 if(AlILinesBusy—0){ dιsplayState( \rphldle_2 ), 681 //Release the seized line by no longer sending ♦endif 682 //it spch packets, and reset eol swιtch(PcRetValue){ 683 SpchMailStruct eol-0, case PC_0K 684 CodecSrcFlag-0, /*-- */ 685 sendMsgInLιne(spchMaιlLιst[0] addr node,LC_PH_SPCHMAILLIST,\ CodecSrcFlag-1, 686 LC_PH_SPCHSINK,SPCH_FL0W_0FF), CodecTxControl-STD.CALL , 687 } PhPtr-phGetFi rstKey, 688 PhPtr phGetSecondKey, break, 689 } 690 else{ case ERR_LINE_INACTIVE 691 ιf(AllLmesBusy){ /*- - */ 692 //Play lines busy" track //This has been inserted to ensure the line has 693 smPlaySιngleTrack(LC_BUSY,phIdle), //been properly seized If this is encountered we need 694 } //to re-seize the line Basic pheno needs further 695 else{ //investigation 696 PsnAdded=l, //The set prior to steady state smGetlme(phIdle_l) , 697 PhPtr-phSteadyState, break, 698 } 699 } default 700 } /* */ 701 //This is a trap for all other errors 702 PhPtr-phldle, 703 ♦define EXTENSION NUM GpRetValue Appendix Appendix Appendix Appendix 98 smPlαySingleTrαck(BING.phConfCαllAddStαrt) ; 845 ιf(localDtmf()){ 99 846 smGetLine(phConfCallAddStart_3); 00 847 } 01 848 break; 02 849 03 850 default: 04 void phConfCαllAddStαrt(){ 851 / . . / 05 ************************* 852 //Was not an attempt to add caller. 06 /* 853 PhPtr=phSteadyState; 07 04/29/98 11:55 am 854 return; 08 See notes on the conf call methodology. 855 09 856 10 04/09/9808:45 am 857 } 1 1 The DTMF tones for conf calls were found to be recognised by all 858 1 2 participants. To overcome this the Rx channel on all phones will 859 void phConfCallAddStart_l(){ 1 3 be disconneted for 150ms and the DTMF valid signal re-sampled. 860 /•**♦♦************•***•**** 14 Only that channel that is generating the tone will continue to 861 ♦ifdef SM_TRACE ■ 1 5 have a DTMF valid signal. 862 displayState("\rphConfCallAddStart_l"); 16 863 ♦endif 1 7 */ 864 18 ♦ifdef SM_TRACE 865 switch(GpRetValue){ 19 displayState("\rphConfCallAddStart"); 866 case GP_N0T_FOUND: 20 ♦endif 867 / . . / 21 868 smPlaySingleTrack(INVALID,phSteadyState); 22 ♦define GP_PHN_NUM GpRetValue 869 return; 23 if (Dtmf In. active— 1){ 870 24 //By NOT clearing the Dtmfln. active flag the 871 case GP_NO_ANSWER: 25 //smGetPhone will operate correctly. 872 / . . / 26 switch(DtmfIn.digit){ 873 smPlaySingleTrack(NO_ANS,phSteadyState); 27 //ø->4 is an internal extention call . 874 return; 28 case 0: 875 29 case 1: 876 case GP-BUSY: 30 case 2: 877 /* ♦ / 31 case 3: 878 s PlaySingleTrack(PH_BUSY,phSteadyState) ; 32 case 4: 879 break; 33 / . . / 880 34 stayAliveO; 881 case GP_ERR0R: .35 PrivateFlag-1; 882 /* */ 36 //The smGetPhone will get the dialed 883 smPlaySingleTrack(PROBLEM, phSteadyState) ; 37 //number and ring the extension. 884 break; I38 smGetPhone(phConfCallAddStart_l); 885 I39 break; 886 case GP_FALSE_DTMF : I40 887 case GP_USER_EXIT: 141 case 0x09: 888 /* */ 142 /♦ ./ 889 PhPtr=phSteadyState; 143 //Detected the key seq "♦9" to add an 890 break; 144 //outside line to the call . 891 Appendix Appendix !92 default: 939 593 /* •/ 940 swιtch(GlRetValue){ !94 //Phone off hook received. Establish a voice 941 case GL_ALL_LINES.BUSY: 195 //connection. 942 / . */ !96 PrivateNode=GP_PHN_NUM; 943 smPlaySingleTrack(LC_BUSY,phSteadyState); 197 //Establish speech channel to private node 944 PrivateFlag=0; 198 smPrivConnect(PrιvateNode,phConfCallAddStart_2); 945 break; 199 946 100 } 947 default 101 948 /* */ 102 void phConfCallAddStart_2(){ 949 //If here GlRetvalue is the node number 103 / * ** ** * * *.*• ****** *•* ***** */ 950 //of the acquired PSN. 104 ♦ifdef SM_TRACE 951 //PsnAdded-1; 105 uchar str[3]; 952 PrιvateNode=GlRetValue; 106 dιsplayState('\rphConfCallAddStart_2"); 953 smPrivConnect(PrivateNode,phConfCallAddStart_2); 107 ♦endif 954 108 955 ι09 swιtch(PcRetValue){ 956 '1 0 case PC_0K: 957 void phConfCallAddEnd(){ 1 1 / . • / 958 » ** **** *••* * * * ****•** * 1 2 //At this point we have a speech channel 959 //If here then a private connect to the new member 1 3 //thro' to the new member. 960 //has been established. User needs to determine when 14 PhPtr=phConfCallAddEnd; 961 //and if the new member is to be added to the group. 1 5 break; 962 // '♦' := Add to the group. 1 6 963 // '*' := Drop the connection. 1 7 case PC_ERR0R- 964 ♦ifdef SM.TRACE 1 8 / » . / 965 dιsplayState( XrphConfCallAddEnd"); 1 9 //If an error is encountered announce the 966 ♦endif 20 //problem and continue with the conf call. 967 21 smPlaySingleTrack(PR0BLEM,phSteadyState); 968 if (Dtmf In actιve){ 22 break; 969 Dtmfln. actιve=0; 23 970 i f (Dtmf In . di gi t— P0UND_KEY) { 24 default 971 ιf(localDtmf()){ 25 / . ./ 972 //Add the new party to the group. 26 ♦ifdef SM-JRACE 973 smAddToGrp(PπvateNode, phSteadyState); 27 formatHexUchar(str,PcRetValue); 974 } 28 putsUart2("\rDrop thro' in AddStart_2, ret val - 0x",str); 975 } 29 ♦endif 976 else{ 30 PhPtr=phSteadyState; 977 i f (Dtmf In . di gi t— STAR_KEY){ 31 } 978 ιf(localDtmf()){ 32 } 979 //Drop the connection. 33 980 PrιvateFlag=0; 34 void phConfCallAddStart_3(){ 981 PhPtr=phSteadyState ; 35 /* *• ***** **.* * * • • * • *** * ** * * / 982 } 36 ♦ifdef SM-.TRACE 983 } 37 dιsplayStateC\rphConfCallAddStart_3"); 984 38 ♦endif 985 Appendix Appendix 386 033 we would not have recognized the ring signal in the 387 034 first place) 388 035 The only other possibility is the ring signal itself 389 /* Answer Ringing from other Phone 036 was bogus, possibly the corruption of some entirely 390 /._,________»»->«,»—»-»«««-..»»«»»»>«.».«»<»<.-. 037 differnet message. 391 038 */ 392 void phRpsAnsPhone(){ 039 393 /***************** . */ 040 void phRpsAnsPsn(){ 394 //Send an off hook msg to the parent 041 / ** * **************/ 395 042 //Try a seize the line from the ringing phone 396 ♦ifdef SM_TRACE 043 ♦ifdef SM.TRACE 397 dιsplayState( XrphRpsAnsPhoπe"), 044 dιsplayState( XrphRpsAnsPsn"), 398 ♦endif 045 ♦endif 399 046 300 ιnιtScrιpts(Rιng.node,PH_H00KRECEPT0R); 047 mιtScπpts(Rιng node.LCLINESEIZE); -01 Scr i pts [PH_APPINTF] . payLen-1 ; 048 Scrιpts[PH_APPINTF] .payLen-1; 302 Scπpts[PH_APPINTF] .up.payData-l; //off hook 049 Scrιpts[PH_APPINTF].up.payData-l; 303 postTxQueue(84Scπpts[PH_APPINTF]); 050 postTxQueue(&Scrιpts[PH_APPINTF]); 304 PhPtr=phRpeAnsPhone; 051 PhPtr=phRpeAnsPsn, D05 052 306 053 307 void phRpeAπsPhone(){ 054 void phRpeAnsPsn(){ 308 055 /******.******♦♦*»/ 309 ♦ifdef SM.TRACE 056 ♦ifdef SM_TRACE 310 dιsplayState("\rphRpeAnsPhone"); 057 dιsplayState( XrphRpeAnsPsn"); 31 1 ♦endif 058 ♦endif 31 2 059 31 3 ιf(Scrιpts[PH_APPINTF].rpEnded—1){ 060 if((PhnAppTimer—0) 11 (Scπpts[PH_APPINTF] .rpError—1)){ 314 if(Scπ ts[PH_APPINTF].payLen—1){ 061 goto LblErrorRecover, 31 5 //We can now return to phSteadyStateO 062 } 01 6 //as the parent takes responsibility for 063 ιf(Scrιpts[PH_APPINTF].rpEnded==l){ 317 //updating mailing list etc. 064 if(Scrιpts[PH.APPINTF].payLen—1){ 31 8 PhPtr=phSteadyState; 065 swιtch(Scrιpts[PH_APPINTF] up payData){ 019 } 066 case 0 020 } 067 /*—-♦/ 021 068 //Connection made. 022 069 //Envoke the "include new member' 023 070 //sub-state machine 024 /* Answer Ringing from PSN */ 071 smlnitConnect(Rιng node,phSteadyState); 025 /* */ 072 break, 026 073 027 074 case 1 028 Error Reporting Note: 075 /*---*/ 029 Given self is receiving msgs from the PSN the range 076 //Line busy - already picked up 030 of possible problems is much reduced, as we know, for example 077 smPlaySi ngleTrack(PICKUP , phSteadyState) ; 031 - the node exists and is functioning 078 break; 032 - it can send msgs to self without error - (otherwise 079 Appendix Appendix θθΦθ-(jco ruιcoNcoσϊθ4-Nrn^-iΛtD (θσ>θ-rjr 4tι/ωNooσ)θr-Nm4rtn(DNeomθ-(ιr r (\!c\j<r>roroc^cnrocororooo^^ ' ^-^-^-rτr^^t riΛLθιiL Lnι/)U3i/iL^ o«— iM<4isj-i/ tON_m (βωωraraco o(otDoo OOOOOOOOOO Notes on the conference c 1. To be a conference ca conversation 2. After the appropraite the initiator ignores establishes a channel In the case of outsid the line and stream c In the case of an int and only on the new p connection establishe 3. Now in both cases the or dropping the conne of all parties are up 34 /• */ 05 PhPtr-phldle; 06 D7 08 09 10 void ph aitOnAnnouncementCX 11 /***♦♦♦*****•*•**•**»*»***»♦/ 12 #lfdef SM TRACE 13 displayStateC Xrph ai OnAnnouncement"); 14 #endιf 15 16 if(SpchSeqActιve«=0){ 17 PhPtr-phldle; 18 } 19 20 Appendix Appendix

Claims: Claims: 1. A distributed processing system, comprising: a first plurality of cells, each cell being responsive to an event and each cell including at least one executable script which is executed upon the occurrence of the event; and a first communications means coupled to each of said cells in said first plurality of cells for exchanging messages between cells. 2. A distributed processing system according to claim 1, further comprising: a second plurality of cells; and a second communications means coupled to said first and second pluralities of cells for exchanging messages between said first and second pluralities of cells. 3. A distributed processing system according to either of claims 1 or 2, wherein: each cell includes dispatcher means for receiving messages and for causing said at least one script to be executed. 4. A distributed processing system according to any previous claim, wherein: said first communication means includes buffer means for temporarily storing messages. 5. A distributed processing system, comprising: a first plurality of processing cells, each cell being responsive to an event and each cell including at least one executable script which is executed upon the occurrence of the event; and a first communications means coupled to each of said cells in said first plurality of cells for exchanging messages between cells, wherein at least one of said processing cells includes an executable script which periodically advertises its presence in the system. 6. A distributed processing system according to claim 5, further comprising: a second plurality of cells; and a second communications means coupled to said first and second pluralities of cells for exchanging messages between said first and second pluralities of cells, wherein at least one of said cells in said first plurality of cells periodically advertises the presence of said first plurality of cells in the system, and at least one of said cells in said second plurality of cells periodically advertises the presence of said second plurality of cells in the system. 7. A distributed processing system according to either of claims 2 or 6, wherein: said second communications means includes a transmitter cell and a receiver cell. 8. A distributed processing system according to claim 7, wherein: said transmitter cell includes a queue manager script. 9. A distributed processing system according to any previous claim, wherein: at least some of said first plurality of cells acts as master to one process and a slave to another process. 10. A distributed processing system according to any previous claim, wherein: each cell includes means for periodically advertising its presence in the system. 11. A distributed processing system according to any previous claim, wherein: each cell maintains a database of all of the scripts in the distributed processing system. 12. A distributed processing system according to claim 8, wherein: said queue manager manages data transfer according to an event reaction protocol. 13. A distributed processing system according to claim 12, wherein: said queue manager also manages data transfer according to a streaming protocol, and said queue manager has means for determining which data to transfer according to a streaming protocol and which data to transfer according to an event reaction protocol. 14. A distributed processing system according to claim 8, wherein: said queue manager manages data transfer according to mailing lists. 15. A distributed processing system according to claim 14, wherein: said mailing lists are subscribed to by at least one of scripts and cells. 16. A distributed processing system, comprising: a) a plurality of processing zones, each processing zone being responsive to an event and each processing zone executing at least one script in response to the event; b) communication means coupled to each of said processing zones for exchanging messages between processing zones, wherein at least one of said processing zones acts as master to one process and a slave to another process. 17. A distributed processing system, comprising: a) a plurality of processing zones, each processing zone being responsive to an event and each processing zone executing at least one script in response to the event; b) communication means coupled to each of said processing zones for exchanging messages between processing zones, wherein at least one of said processing zones includes a script which periodically advertises its presence in the system. 18. A distributed processing system according to claim 17, wherein: at least one of said processing zones includes a script which periodically advertises the presence of said plurality of processing zones in the system. 19. A distributed processing system according to any of claims 16-18, wherein: said communication means includes a multiported shared memory. 20. A distributed processing system according to any of claims 16-19, wherein: at least one of said processing zones includes means for coupling it to at least one of a peripheral device and a network. 21. A method of distributing processes in a distributed processing system, comprising: a) creating a plurality of processing zones, each processing zone being responsive to an event; b) assigning at least one script to each processing zone, the script being executed by the zone in response to the event; and c) providing means for the zones to communicate with each other. 22. A distributed processing system, comprising: a) a plurality of nodes, each node including a plurality of processing cells, each processing cell being responsive to an event by executing at least one script; and b) a communication medium coupling said plurality of nodes such that a script executed in one node causes a message to be sent over said communication medium to a cell in another node. 23. A distributed processing system according to claim 22, wherein: each node includes a transmitter cell and a receiver cell, said transmitter cell and said receiver cell being coupled to said communication medium and forming an interface for said processing cells of said node to said communication medium. 24. A distributed processing system according to either of claims 22 or 23, wherein: at least one node includes an input for receiving data external of said node, said input coupled to one of said processing cells in said node. 25. A distributed processing system according to any of claims 22-24, wherein: at least one node includes an output for providing data external to said node, said output coupled to one of said processing cells in said node. 26. A distributed processing system according to any of claims 22-25, wherein: each node includes at least one processor means for implementing processing cells. 27. A distributed processing system according to claim 26, wherein: each node contains a multi-ported shared memory with which cells in the node communicate with each other. 28. A distributed processing system according to claim 26, wherein: each script which communicates over said communications medium has a data structure associated with it for handling messages which travel over said communications medium. 29. A distributed processing system according to any of claims 22-26, wherein: at least one of said processing cells act as both master processor controlling another processing cell for one process and slave processor being controlled by another processing cell for another process. 30. A distributed processing system according to any of claims 22-29, wherein: each node includes means for advertising its presence in the distributed processing system. 31. A distributed processing system according to any of claims 22-30, wherein: each node contains means for maintaining a mailing list and means for subscribing to a mailing list maintained by another node. 32. A distributed processing system, comprising: a) a plurality of nodes, each node including a plurality of processing cells, each processing cell being responsive to an event by executing at least one script; and b) a communication medium coupling said plurality of nodes such that a script executed in one node causes a message to be sent over said communication medium to a cell in another node, wherein each node includes a transmitter cell and a receiver cell, said transmitter cell and said receiver cell being coupled to said communication medium and forming .an interface for said processing cells of said node to said communication medium, at least one node includes an input for receiving data external of said node, said input coupled to one of said cells in said node, and at least one node includes an output for providing data external to said node, said output coupled to one of said cells in said node. 33. A distributed processing system according to claim 32, wherein: at least one cell acts as master to one process and a slave to another process. 34. A distributed processing system according to claim 32 or 33, wherein: each of said nodes includes means for periodically advertising its presence in the distributed processing system. 35. A distributed processing system according to any of claims 32-34, wherein: at least some cell have means for maintaining a mailing list for sending messages to other cells, and at least some cells have means for subscribing to mailing lists in response to said nodes periodically advertising their presence. 36. A distributed processing system, comprising: a) a plurality of processing zones, each processing zone being responsive to an event by executing at least one script; and b) a communication medium coupling said plurality of zones such that a script executed by one zone causes a message to be sent over said communication medium to another zone, wherein some messages are streaming data which does not require acknowledgment and some messages are sent according to an event-reaction protocol which requires acknowledgement. 37. A distributed processing system according to claim 36, wherein: said plurality of processing zones comprises a plurality of nodes with each node including a plurality of processing cells which are physically located local to each other, and each node includes a transmitter cell and a receiver cell, said transmitter cell and said receiver cell being coupled to said communication medium and forming an interface for said node to said communication medium. 38. A distributed processing system according to claim 37, wherein: at least one node includes an input for receiving data external of said node, said input coupled to one of said cells in said node. 39. A distributed processing system according to either of claims 37 or 38, wherein: said transmitter cell includes means for determining whether a message will be sent as streaming data or according to an event-reaction protocol. 40. A distributed processing system according to any of claims 37-39, wherein: at least one node includes an output for providing data external to said node, said output coupled to one of said zones in said node. 41. A distributed processing system according to any of claims 37-40, wherein: each node includes at least one processor. 42. A distributed processing system according to any of claims 37-41, wherein: each node includes a multi-ported shared memory with which zones in the node communicate with each other. 43. A distributed processing system according to any of claims 36-42, wherein: each script which communicates over said communications medium has a data structure associated with it for handling messages which travel over said communications medium. 44. A distributed processing system, comprising: a) a plurality of nodes, each node including a plurality of processing zones, each processing zone being responsive to an event by executing at least one script; and b) a communication medium coupling said plurality of nodes such that a script executed in one node causes a message to be sent over said communication medium to a cell in another node, wherein some messages are streaming data which do not require acknowledgment and some messages are sent according to an event-reaction protocol which requires acknowledgment. 45. A distributed processing system according to claim 44, wherein: at least one zone acts as master to one process and a slave to another process. 46. A distributed processing system according to either claim 44 or 45, wherein: each of said nodes includes means for periodically advertising its presence in the system. 47. A distributed processing system according to any of claims 44-46, wherein: each zone maintains a mailing list for sending messages to other zones. 48. A distributed processing system according to claim 47, wherein: zones subscribe to mailing lists in response to said nodes periodically advertising their presence. 49. A distributed processing system, comprising: a) a first plurality of processing zones, each being responsive to an event and each executing at least one script in response to the event; b) first communication means coupled to each of said first plurality of processing zones for exchanging messages between processing zones, wherein at least one of said first plurality of processing zones maintains a mailing list of processing zones for sending messages. 50. A distributed processing system according to claim 49, wherein: at least one of said first plurality of processing zone includes means for subscribing to a mailing list. 51. A distributed processing system according to either of claims 49 or 50, wherein: at least one of said first plurality of processing zones includes an executable script which periodically advertises its presence in the system. 52. A distributed processing system according to any of claims 49-51 , further comprising: c) a second plurality of processing zones; and d) a second communications means coupled to said first and second pluralities of processing zones for exchanging messages between said first and second pluralities of processing zones, wherein at least one of said second plurality of processing zones includes an executable script which periodically advertises the presence of said second plurality of processing zones in the system, and said at least one of said first plurality of processing zones includes a script which is responsive to advertising by said at least one of said second plurality of processing zones by updating said mailing list to include said second plurality of processing zones. 53. A distributed processing system according to claim 52, wherein: said second communications means includes a transmitter processing zone and a receiver processing zone. 54. A distributed processing system according to claim 53, wherein: said transmitter processing zone includes a queue manager script. 55. A distributed processing system according to any of claims 49-54, wherein: at least some of said first plurality of processing zones acts as master to one process and a slave to another process. 56. A distributed processing system according to any of claims 49-55, wherein: at least one of said first plurality of processing zones maintains a database of all of the scripts in the system. 57. A distributed processing system according to any of claims 49-56, wherein: each processing zone periodically advertises its presence in the system, and said database is updated in response to advertising by said processing zone. 58. A distributed processing system according to claim 54. wherein: said queue manager manages data transfer according to an event reaction protocol requiring that receipt of data be acknowledged. 59. A distributed processing system according to claim 58, wherein: said queue manager also manages data transfer according to a streaming protocol in which receipt of data is not acknowledged, and said queue manager has means for determining which data to transfer according to a streaming protocol and which data to transfer according to an event reaction protocol. 60. A distributed processing system according to any of claims 49-59, wherein: said first communication means includes a multiported shared memory. 61. A distributed processing system according to any of claims 49-60, wherein: at least one of said first plurality of processing zones includes means for coupling itself to at least one of a peripheral device and a network. 62. A distributed processing system, comprising: a) a plurality of nodes, each node including a plurality of processing zones, each processing zone being responsive to an event by executing at least one script; and b) a communication medium coupling said plurality of nodes such that a script executed in one node causes a message to be sent over said communication medium to a cell in another node, wherein at least one processing zone maintains a mailing list of processing zones for sending messages. 63. A distributed processing system according to claim 62, wherein: at least one processing zone includes means for subscribing to a mailing list. 64. A private branch exchange (PBX) system for use with one or more subscriber lines in a home or office, said PBX system comprising: a) a first line card adapted to be coupled to a first subscriber line, said first line card including a plurality of line card cells, each line card cell being responsive to an event and each line card cell including at least one executable line card script which is executed upon the occurrence of the event; and b) at least two first phone cards, each adapted to be coupled to said first subscriber line and to a telephone device, each phone card including a plurality of phone card cells, each phone card cell being responsive to an event and each phone card cell including at least one executable phone card script which is executed upon the occurrence the event, wherein said first line card and said first phone cards exhibit a symmetrical and reciprocal relationship wherein each card is master to at least one process and slave to at least one other process. 65. A system according to claim 64, further comprising: c) a second Line card adapted to be coupled to a second subscriber line, said second line card including a plurality of line card cells, each line card cell being responsive to an event and each line card cell including at least one executable line card script which is executed upon the occurrence of the event; and d) a line bridge coupled to said first subscriber line and said second subscriber line wherein said second line card and said first phone cards exhibit a symmetrical and reciprocal relationship wherein each card is master to at least one process and slave to at least one other process. 66. A system according to claim 65, further comprising: e) at least one second phone card adapted to be coupled to said second subscriber line and to a telephone device, each second phone card including a plurality of phone card cells, each phone card cell being responsive to an event and each phone card cell including at least one executable phone card script which is executed upon the occurrence the event, wherein said first line card and said second phone cards exhibit a symmetrical and reciprocal relationship wherein each card is master to at least one process and slave to at least one other process. 67. A system according to any of claims 64-66, wherein: said first line card and said at least two first phone cards each include means for advertising their presence to each other via the first subscriber line. 68. A system according to claim 66, wherein: said first line card, said second line card, said at least two first phone cards, and said at least one second phone card each include means for advertising their presence to each other via the first and second subscriber lines and said line bridge. 69. A system according to claim 67, wherein: at least said first line card and said at least two first phone cards each include means for maintaining a mailing list and means for subscribing to each other's mailing lists in response to advertising. 70. A system according to any of claims 64-69, wherein: at least said first line card and said at least two first phone cards communicate via messages where some messages are streaming data which does not require acknowledgment and some messages are sent according to an event-reaction protocol which requires acknowledgement. 71. A system according to any of claims 64-70, wherein: said plurality of line card cells includes a seize subscriber line cell responsive to a message from one of said at least two first phone cards. 72. A system according to claim 71, wherein: said plurality of phone card cells includes an off-hook cell which responds to an off- hook event by sending a message to said seize subscriber line cell. 73. A system according to claim 72, wherein: said seize subscriber line cell includes an executable script which sends a message to a phone card cell indicating whether the subscriber line is in use.

Inventors: ROBINSON JEFFREY I, ROBINSON, JEFFREY, I.
Applicants: IQ SYSTEMS INC, ROBINSON JEFFREY I, IQ SYSTEMS, INC., ROBINSON, JEFFREY, I.
Application year: 2000
Main classification: G06F
IPC codes: G06F9, G06F15, H04L29, H04M3