550 563 03 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RS232 Communication channel
The function of a Communication Channel is to provide a mechanism for transferring data externally using different electrical standards to form a communication Port. The actual electrical interface is achieved by means of hardware, but the channel registers provide the user with facilities for selecting transfer timings and format, and for reading and writing data.
Connection to the RS232 Communication channel is made via an RJ45 connector or the terminals mounted on the associated base module.
Each time a write operation is made to one of the variables SpecialFeatures, NodeParam, Baudrate, ChConfig or DatamodeParam, and WriteEnable is True, the channel is initialised, in accordance with the new contents of the variables. This is also the case if a write operation is made to NodeParam via the Service Channel, PNETSerialNo. Therefore, a delay of several seconds should be expected before these write operations are completed.
If the configuration of the communication channel is set up in an inappropriate way, it may be impossible to re-establish any contact with the device. To work around this problem, the following functionality applies: Following a MasterReset, an RS232 communication channel is set to P-NET protocol at 115.2 Kb/s, SpecialFeatures.Flags[7] true (Full Duplex). In this situation, the actual setting used cannot be read. What is read is the setting in the EEPROM, making it possible to see, how the channel will work after a normal reset. Following a normal reset, or start of operating system in FLASH, the device will use the configuration selected in the EEPROM again.
Variables in a Communication Channel
RegNo. 0: OutputBuffer
When configured to Data mode Out (ChConfig.Functions = DatamodeOut or DatamodeInOut), data written to this buffer will be sent to the port. Data is transmitted when there is at least one element in the buffer. Only the number of bytes corresponding to the actual length of the string is sent. The string length (1st byte) is NOT sent. When writing to OutputBuffer, the ReserveTimer is pre-set with the value found in ReservePreset.
RegNo. 1: InputBuffer
When configured to DatamodeIn (ChConfig.Functions = DatamodeIn or DatamodeInOut), data received at the port is transferred to this buffer. Data is transferred to the buffer according to the conditions described under DatamodeParam. The string length (1st byte) is calculated and inserted - NOT received. Transferring an element to the InputBuffer may generate a Software-interrupt.
RegNo. 2: Handshake
In a PD 601 DPI, the RS 232 handshake signals can be read in this variable. In addition, the RTS and DTR signals can be controlled manually.
The signals are described in the following:
A True bit value indicates that the corresponding signal is in the active state.
If Handshake is True (refer to ChConfig), transmission is controlled by the CTS input signal. Each time a master request, a slave response or data from the OutputBuffer is to be sent, CTS is checked. When CTS becomes active, transmission starts. If CTS becomes inactive during transmission, the byte currently being sent is transmitted, transmission stops, and resumes when CTS becomes active again. If Handshake is False, the transmitter does not check the state of CTS. If Handshake is True, the InputBuffer controls the state of the RTS output signal. The RTS signal is True when the device is ready to receive. If the InputBuffer becomes full, RTS is set inactive, until the InputBuffer is no longer full. If Handshake is False, RTS is always True. The Ring Indicator signal is not connected when the RJ45 connector is used.
RegNo. 3: SpecialFeaturesThis variable is a record having the following structure:
This record is used to define special functions for the communication channel.
Flags
SpecialFeatures.Flags
Following a Master reset, all flags will be false. Performing a normal reset will restore the settings from the EEPROM.
Bit 0 If No write access is True, it means that no P-NET write requests are legal on this port. Any P-NET request holding one of the instructions STORE, AND, OR, TAS or LONGSTORE will result in a "Write protection" response. This goes for all requests, whether they are requests for this device, or gateway requests. Bit 1 If No access is True, it means that no P-NET requests are legal on this port. In other words, this port only works as a P-NET master. Any P-NET slave request will result in a "Write protection" response. This goes for all requests, whether they are requests for this device, or gateway requests. Bit 2 Not used Bit 3 Not used Bit 4 Not used Bit 5 If “PD 3000 Compatible” is set True, the DPI will be able to function as a gateway between a PC and a PD 3000 controller. The “PD 3000 Compatible” flag must be set True for the port connected to the PD 3000 controller. Bit 6 This facility is related to gateway requests only. A master requesting a slave through a gateway, first receives “Answer comes later” from the gateway, and later on receives the “Later answer”. This “Later answer” is an Unconfirmed Request. If Acknowledge Unconfirmed Request is True, the receipt of unconfirmed P-NET requests (Later answers) will be acknowledged by the operating system automatically sending an immediate reply. Unconfirmed requests are requests holding "Later answers". This facility can be used to automatically retransmit unconfirmed requests the number of times indicated by Retries for the transmitting channel, if the transmitting channel receives no acknowledge from the receiving node. The value of Acknowledge Unconfirmed Request MUST be the same for all masters on the same link. By default, Acknowledge Unconfirmed Request is False. Setting Acknowledge Unconfirmed Request to True can improve performance with very noisy connections. Bit 7 To improve readability, the two meanings of this bit are described independently. The same bit selects the two functions, because they are closely related on RS232 ports, and to avoid illegal combinations of settings. If Full Duplex is True, it means that on this channel it is possible to send and receive data simultaneously. The facility is used to speed up communication, as it makes it legal to transmit new requests before a response is received for former sent requests. If Full Duplex is False, it is not legal to send a new request before a response is received from formerly sent requests. This is the case, even if "Answer Comes Later" is received, as this could result in a collision between the "later answer" and the new request. In this case, the channel is set into "RS232 Wait State", and waits for up to 5 seconds for the "Later answer" request holding the response. If Don't Acknowledge Confirmed Request is False, the receipt of confirmed requests will be acknowledged. The immediate reply will typically hold the response. If Don't Acknowledge Confirmed Request is True, immediate reply will never be sent when this channel is a slave, and will never be expected from slaves when this channel is a master. All "responses" will instead be sent as "later answers", which are new requests including at least 2 destination addresses. This facility is used to speed up MODEM connections. In MODEM connections it takes some time from when data is sent into the MODEM until it is received on the other MODEM. In other words, it takes a fixed minimum time to send a frame. In this time, it will often be possible for the other channel (to which the gateway request is sent) to send a whole request and receive a whole response. Therefore, by not sending “Answer Comes Later”, the transmission time is reduced by approximately half. The value of Full Duplex / Don't Acknowledge Confirmed Request MUST be the same for all devices on the same link.
MaxResponseTime The value of this variable defines for how many seconds this device should wait for a response after sending a request if Full Duplex is selected, and after receiving “Answer comes later” if Full Duplex is not selected. If no response is received within the specified time, the P-NET error “TIME OUT” is generated. Note: Only FLASH OS version 1.19 or higher.
RegNo. 4: MODEMParamThis variable is a record having the following structure:
PhoneNumber, HangupDelay, MaxWait If MODEMMode in ChConfig.Enablebit is True, and PhoneNumber holds a non-zero length string, a call is made to the phone number defined in PhoneNumber under one of the following conditions: a) If the channel is in P-NET mode, and a request is to be sent, and a connection is not already established to the number defined in PhoneNumber. If a connection is already established to another phone number, this connection is first terminated. b) If the channel is in Datamode, and an element from the OutputBuffer is to be sent, and a connection is not already established to the number defined in PhoneNumber. If a connection is already established to another phone number, this connection is first terminated. If a connection has been automatically established as described above, it will be automatically terminated after the number of seconds defined in HangupDelay. If the value of HangupDelay is 0, the connection will not be terminated automatically. During automatic establishment and termination of a connection, the number of seconds in MaxWait defines how long a period connection / disconnection may take. If the connection has not been established or terminated within this time, a "MODEM connect error" is generated. PhoneNumber shall only hold the phone number. The operating system automatically appends “ATD” in front of the phone number before it is sent to the MODEM.
PINCode PINCode is a placeholder for a PIN-Code for the MODEM. The operating system in the DPI does not use this field for anything.
UserString1, UserString2 These 2 strings are not used for anything by the operating system, but can be used to store any user information.
RegNo. 5: NodeParamThis variable is a record having the following structure:
This variable holds the node parameters for the communication channel. The values of these registers may also be changed via Service.PNETSerialNo. When this is done, the values are always transferred to the EEPROM, regardless of the state of WriteEnable.
PNETNoPNETNo defines the P-NET number (P-NET Node Address) of the channel.
NoOfMastersNoOfMasters defines the number of masters for the channel.
RegNo. 6: Baudrate
This variable selects the baud rate for the communication channel. If an illegal baud rate is selected, an error code is generated. For P-NET mode, baud rate can hold the values 230400, 115200, 76800, 57600, 38400, 19200, 9600 or 4800. For data mode, baud rate can also be 2400, 1200, 600 or 300.
Following a master reset, the default baud rate will be selected. Performing a normal reset will restore the value from the EEPROM.
RegNo. 7: Retries
This register defines the maximum number of retries made in case of transmission error, before the error is reported. The register only has meaning if the channel is a master. The defined maximum number of retries is for each block in a LONG LOAD / STORE. Therefore, the value of Retries should be very low.
RegNo. 8: ReserveTimer
ReserveTimer is automatically preset with the value from ReservePreset, each time the channel is reserved (Reservation Boolean set True by TestAndSet), and each time a string is sent to the OutputBuffer. If the ReserveTimer reaches zero before it is preset again, the Reservation Boolean will be cleared automatically, and the error Reservation timeout will be generated. The ReserveTimer may also be preset by direct access.
RegNo. 9: ChConfigThis variable is a record having the following structure:
The ChConfig variable allows the user to determine which of the available functions in this channel are to be used. EnablebitChConfig.Enablebit
If Simulation is selected, writing to the InputBuffer is legal, and data from the port will be ignored. Refer to DatamodeParam for a description of DatamodeIn flags. If DatamodeOut Add CR LF automatically is selected, the two characters CR and LF ($0D and $0A) are always sent immediately after an element from the OutputBuffer has been sent. SMSMode is used to enable P-NET functionality as well as Datamode functionality with the same configuration of the channel. This facility is useful, when the channel is used for P-NET communication as well as for receiving and transmitting SMS (Short Message Service) messages. When the MODEM is on-line (DCD handshake signal ON) the channel is in P-NET mode (if selected in ChConfig.Functions). When the MODEM is off-line (DCD handshake signal OFF) the channel is in Datamode. If the MODEM receives an SMS message while it is on-line, the message is stored in the unit until it goes off-line (provided the MODEM offers this facility), at which time the message is reported. The report will then be transferred to the InputBuffer. If an SMS message is written to the OutputBuffer while the MODEM is on-line, the message will stay in the OutputBuffer until the MODEM goes off-line. The message will then be sent to the MODEM. The SMS messages sent and received via OutputBuffer and InputBuffer are the whole “AT string” in which the messages are wrapped. Refer to the user manual for your MODEM, to see how SMS messages are sent and received.
Refer to section – RegNo 4: ModemParam for a description of the MODEMMode flag. FunctionsFunctions holds the protocol of the channel:
Ref_A - ParityThe value of this variable defines parity:
Ref_B - NoOfDatabitThe value of this variable defines how many data bits are sent per byte. The number of data bits can be 5, 6, 7 or 8. In P-NET mode, the number of data bits will always be 8, regardless of the value of this variable.
RegNo. 10: ReservePreset
Preset value for ReserveTimer. Refer to ReserveTimer and Reservation for further description.
RegNo. 11: Reservation
This variable is used to reserve the communication channel. The reservation facility is used in relation to DatamodeOut, to prevent mixing of data written to the OutputBuffer from different applications. Reservation = True indicates, that the communication channel is reserved. The variable must be set True with the TestAndSet function, to reserve the communication channel. A TestAndSet access to the Reservation Boolean resulting in a reservation, will pre-set the ReserveTimer with the value found in ReservePreset. When the OutputBuffer is no longer needed, it must be released again by setting Reservation = False.
The Reservation Boolean will be cleared automatically and a Reservation Timeout error will be generated, if the ReserveTimer reaches zero before it is pre-set again (by writing to OutputBuffer).
RegNo. 12: DatamodeParamThis variable is a record having the following structure:
This variable holds parameters concerning DatamodeIn only.
The combination of ChConfig and this variable determines, when data is transferred to InputBuffer.
If ChConfig.Enablebit[3] is True, an element is transferred to the InputBuffer when data has been received, and no further data has been received within the time defined in Pause. The value in Pause is inserted in seconds and has a resolution of approx. 0.001 seconds.
An element is transferred to the InputBuffer when the number of bytes defined in ElementSize have been received. If ElementSize is = 0 or higher than the actual size of an element in InputBuffer, an element is transferred to the InputBuffer when the number of bytes corresponding to the actual size of an element in InputBuffer have been received.
If ChConfig.Enablebit[2] is True, an element is transferred to the InputBuffer when a character equal to StopChar has been received.
If the InputBuffer is full when an element should be inserted, an InputBuffer full error is generated.
Each byte received is in fact transferred directly to the InputBuffer. When the first byte to a new buffer element is received, the buffer element is automatically "reserved" because the "Number of free elements" counter decrements by 1. The received byte is inserted in the buffer element, and the actual length of the string is set to 1. Now, the next bytes received are inserted in the reserved element and the actual length of the string incremented, until one of the conditions for transferring data to InputBuffer is fulfilled. When this occurs, the "Number of elements" counter is incremented by 1, and an interrupt may be generated (if selected).
The counters "Number of free elements" and "Number of elements" are described along with general Buffer facilities in the P-NET Standard.
If ChConfig.Enablebit[1] is True, "Dynamic buffer element sizing" is enabled. Normally, a read access to a buffer with "No of elements" = 0, results in a BufferError (Buffer empty). However, with "Dynamic buffer element sizing" the bytes received at the time of the read operation, are returned. As always, the actual number of bytes is returned in the first byte (the String length). After this read, reception is continued in a new buffer element.
RegNo. 13: MaintenanceThis variable is a record having the following structure:
The Maintenance variable is used for service management and maintenance purposes, and may hold the last date of service and an indication of the type of service.
RegNo. 14: ChTypeThis variable is a record having the following structure:
The ChType variable indicates what type of channel this is, how many channel registers are used, and what functions this channel offers.
ChType has the following values:
ChannelType = 14 (Communication Channel)
Exist =
Functions =
When selection of unsupported Baud rates, Parity modes, protocols etc. is tried, a configuration error is generated in ChError. The error is cleared when correct values are inserted.
RegNo. 15: ChErrorThis variable is a record having the following structure:
ChError for Communication channel
Bit 7 Device error. If this bit is set, the rest of the bits have no meaning because a device error can cause random error codes on the individual channels (see also "Service channel"). Bit 6 InputBuffer overrun error is generated when transferring to the InputBuffer in DatamodeIn is not possible, because the buffer is full. The error is cleared in ChError.Act be reading the InputBuffer. Bit 5 Parity/framing error is generated if parity or framing error is detected on any of the received data for the InputBuffer. The error is cleared in ChError.Act when the InputBuffer is read. Bit 4 Reservation Timeout is generated if the Reservation boolean is cleared because the Reservation timer reached zero. The error is cleared in ChError.Act by writing to the Reservation variable. Bit 3 Configuration error is generated when an illegal configuration is attempted. The error is generated in ChError.His and in ChError.Act. The error is cleared in ChError.Act by a legal write operation (a legal configuration). Bit 0 MODEM connect error is generated when automatic connection via MODEM fails. The error is cleared when automatic MODEM connection is successful.
|