Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example of the communication through fone modem (PmModem object)

Example is placed in the folder: /Pm/Examples/Commun/Modem. There are two applications (Master and Slave).
 
This is an example of data communication between two applications by means of the serial protocol PmNET0 through modems. The Slave application offers data - the modem waits for calling. The Master application sends or reads the data - the PmModem object dials the number and after dialing the data are read (send) by means of the PmCommMsg object.
 
A computer with a modem is needed for the correct behaviour of the example with already installed driver configured for the telephone network. For the full testing the communication using the modem, two computers connected by modems are recommended. Start the Modem Slave application on one PC and start the Modem Master application on the other PC.
 

Modem Master

After starting, the window for setting the phone number of the computer with the Modem Slave application (data provider) opens first. After setting the number, the window to control the communication opens. The operator has available the "Start communication" button, by which the data from the "Modem Slave" application are read (from provider), and the "Send null data" button, by which the initial (null data) are sent to the provider and new (current) data are read from the provider afterwards. The read data are shown on the data panel. The visualization of the communication (modem) status is provided in a separate window.
 
Description how application is implemented:

The Modem Master application is an example of the communication, getting and sending data through phone lines by a modem. The whole object "ModemMaster" can be used (after copying and its specification) in the concrete applications where the data for other applications (clients) have to get or send by a modem. List of objects:

- ModemMaster: On the Methods page there is defined the "AddReport" method that serves for reporting logs about the status of the communication.

The object consists from objects:

- Base: Serves for the initial setting of the phone number of the data provider/receiver (client - Modem Slave). On the Methods page there is defined the "OpenWindow" method, by which it is specified which user screen opens as the next. The phone number, set in the initial screen, is stored into the "PhoneNumber" object.

Note: The phone number has to be set with the prefix according to the phone network. It is necessary to manage the delay for switching from the internal to the external phone network.

- Data1: Serves for controlling the communication and storing the data. On the Methods page two methods "Read" and "Write" are defined.
"Read" method - the communication type "reading" is set and the phone number of the provider (Modem Slave) is dialed. The method is called by the "Start communication" button from the operator screen
"Write" method - the communication type "sending" is set and the phone number of the client (Modem Slave) is dialed. The method is called by the "Send null data" button from the operator screen

The read data are stored into the "DataRead" object of the PmData type.

- TypeTransfer: Serves for storing the communication type
- Report: Serves for storing the report about the communication (modem) status.
- Comm: Serves for the communication. The communication protocol is defined here. It consists from objects of the PmCommMsg type:
- Data1Read: here is data reading from client.
- Data1Write: here is data sending to client.

In the onEndOfTransfer event of the both objects the success of the transfer is checked and then is called HangUp method.

- Modem: Serves for controlling the modem. In the "onConnect" event the Run method is called for "Data1Read" or "Data1Write" according to the communication type.
 

Slave modem

After starting the application, the data emulation is started and the modem is automatically set to the "WaitForCall" mode, i.e. waiting for the connection from the other party. The operator can control the data emulation by the following data: "Stop data emulation", "Start data emulation" and "Set data to null". Further, the operator has the"Communication status" window available where the current status of the communication (modem) is shown.
 
Description how application is implemented:

The Modem Slave application is an example of the communication, providing data through phone lines by a modem. The whole object "ModemSlave" can be used, after copying and its specification, in the concrete applications where the data for other applications, users, have to provide by a modem. List of objects:

- ModemSlave: Serves for emulating the data that are further provided to other stations connected by the modem and the telephone network. After starting the application (the "onStart" event), the modem is set to the "WaitForCall" state (waiting for the other party call). After stopping the application (the "onStop" event), the modem is deactivated. On the "Methods" page the "AddReport" method is defined that serves for writing reports in the "Communication status" window.

The object consists from objects:

- Data1: Serves for emulating the data and controlling the application. On the "Methods" page the "NulData" method is defined that serves for setting the emulated data to the initial (null) values. The method is used either by the "Set data to null" button and also by the "Timer" object (see the condition in the script in the onTick event). The "Window" graphic object serves for the visualization of the data, for controlling the data emulation and for the visualization of the communication (modem) status. The "Timer" object serves for emulating the data (see the script in the onTick event). The "Data1" object of the PmData type serves for storing the emulated data.
- Report: Serves for storing reports about the communication status.
- Comm: Serves for the communication. The communication protocol is defined here. The "Data1Read" subobject represents the provided data (for sending). The "Data1Write" subobject represents the received data (for writing).

Note: "Data1Read", "Data1Write" must be of the same data type as "Data1" and the other party must have also the same data type.

- Modem: Serves for controlling the modem. In the "onHangUp" event (after the communication with the other party is completed) the modem is set again into the "WaitForCall" mode.
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice