The POCSAG Unit is a Turbo PASCAL 7.0 Unit wich decodes POCASG streams.
Here is the Interface section of this Unit.
...
Interface
Const FSC = $7CD215D8; { POCSAG Frame Synchronization Codeword }
______ICW = $7A89C197; { POCSAG Idle CodeWord }
______PCW = $55555555; { POCSAG Preamble CodeWord }
______CRC = $0769;_____{ POCSAG CRC Polynomial x^10+x^9+x^8+x^6+x^5+x^3+1 }
____{ 8250 registers }
______MCR = 4;______{ Modem Control Register }
______DTR = $01;____{ 00000001 - See MCR - SUB 25: 20 - SUB 9: 4 }
______RTS = $02;____{ 00000010 - See MCR - SUB 25: 04 - SUB 9: 7 }
______MSR = 6;______{ Modem Status Register }
______CTS = $10;____{ 00010000 - See MSR - SUB 25: 05 - SUB 9: 8 }
______DSR = $20;____{ 00100000 - See MSR - SUB 25: 06 - SUB 9: 6 }
Type TFunctions = (Auto, Beep, Num, Alpha);
_____TDTypes= (CodeWords, Messages);
_____TPolarity= (Positive,Negative);
_____TPOCConf = Record
_________________COMPort : Byte; { 1, 2, 3 or 4 }
_________________COMLine : Byte; { CTS or DSR }
_________________BitRate : Word; { 512, 1200 or 2400 }
_________________DType : TDTypes;
_________________CRCCorr : Boolean; { Enable CRC Correction }
_________________FNCT : Array [0..3] Of TFunctions;
_________________Status : Boolean;
_________________StX,
_________________StY,
_________________StTC,
_________________StTB : Byte;
_________________StS : String [18];
_________________ShowTime: Boolean;
_________________TimX,
_________________TimY,
_________________TimTC,
_________________TimTB : Byte;
________________End;
_____TPOCOutput = Record
___________________DType: TDTypes;
___________________DNbr : Word; { Number of Datas }
___________________RIC : LongInt;
___________________Fnct : Byte;
___________________Mess : String [255];
__________________End;
_____TPOCSend = Record
_________________COMPort : Byte; { 1, 2, 3 or 4 }
_________________COMLine : Byte; { DTR or RTS }
_________________Polarity: TPolarity;
_________________Code : TFunctions;
_________________Rate : Word; { 512, 1200 or 2400 }
_________________RIC : LongInt;
_________________Fnct : Byte; { 0, 1, 2 or 3 }
_________________Mess : String [255];
________________End;
Var POCConf: TPOCConf;
____POCOutput: TPOCOutput;
____POCSend: TPOCSend;
____POCInit: Boolean;
Function Start: Byte;
Procedure Send;
Procedure NextMessage;
Procedure FirstMessage;
Procedure Stop;
...
Just declare Uses POCSAG
in your program.
The POCSAG Unit contains a startup code wich display a copyright window.
If you use this unit, you must begin your program with a Delay (2000)
instruction.
If the POCSAG Unit initialization is goog, the POCInit boolean is True.
So, a good start for a program is
Begin
Delay (2000);
If Not POCInit Then Begin
_____________________POCSAG.Stop;
_____________________ClrScr;
_____________________Halt;
____________________End;
...
After, you have to configure the POCSAG Unit.
The default configuration code is
With POCConf Do Begin
_________________COMPort:=2;
_________________COMLine:=DSR;
_________________BitRate:=1200;
_________________DType :=Messages;
_________________CRCCorr:=True;
_________________FNCT[0]:=Num;
_________________FNCT[1]:=Auto;
_________________FNCT[2]:=Auto;
_________________FNCT[3]:=Alpha;
_________________Status :=False;
_________________StX :=0;
_________________StY :=0;
_________________StTC :=0;
_________________StTB :=0;
_________________StS :='';
_________________ShowTime:= False;
_________________TimX :=0;
_________________TimY :=0;
_________________TimTC :=0;
_________________TimTB :=0;
________________End;
With POCSend Do Begin
_________________COMPort:=2;
_________________COMLine:=DTR;
_________________Polarity:=Positive;
_________________Code :=Alpha;
_________________Rate :=1200;
_________________RIC :=12345;
_________________Fnct :=3;
_________________Mess :='POCSAG UNIT ©1997 BERNARD GALASSO';
________________End;
COMPort
defines the RS232 port to use to get the POCSAG stream in. Any value between 1 and 4 is correct. The Unit found the real port address, so it's easy to use.
COMLine
defines the line to use in the COMPort. It could be $10 or $20. In the unit, CTS and DSR are predefined constant, so use it to define at wich line your HAMCOM interface outputs the stream.
BitRate
defines the stream data speed. You can define 512, 1200 and 2400 bps speed. The unit lookup only the streams a this speed. If you define Bitrate as 0, so the unit will automatically find the data speed of the stream.
NOTE: The unit work for any of the 3 speeds, but only at one of the 3 in the same stream. It means that if you receive a stream containing messages at different speeds, the unit will decode only the messages send at the first speed in the stream.
Ex: Let's see what happen with this kind of stream
Start of the stream
1200 bps messages n°1
512 bps messages n°1
2400 bps messages n°1
1200 bps messages n°2
2400 bps messages n°2
512 bps messages n°2
1200 bps messages n°3
End of stream
If bitrate is set to 512, only the 512 bps messages will be decoded.
If bitrate is set to 1200, only the 1200 bps messages will be decoded.
If bitrate is set to 2400, only the 2400 bps messages will be decoded.
If bitrate is set to 0, only the 1200 bps messages will be decoded because the stream start with a 1200 bps message.
DType
defines what the Unit shall output. See POCOutPut.
CRCCorr
is a boolean. If set to True, the unit makes a CRC error correction of the POCSAG codewords before it interprets them.
FNCT[x]
defines the way a POCSAG function must be intrepreted.
If set to NUM, the associated message is decoded as Numeric message, even if it's an alphanumeric message.
If set to Beep, the associated message is ignored.
If set to Alpha, the associated message is decodea as Alphanumeric message, even if it's an numeric message.
If set to Auto, the associated message is first decoded as Numeric message, and if there is too many errors (characters out of 0..9), then the message is decoded as Alphanumeric message. Decoded by this way, most of messages are decoded as they have to, but with short alphanumerics messages, there could be some errors.
Status
is a boolean wich defines if the unit shall output a Status character during reception. If set to True, StX
and StY
defines the X and Y position of the character, StTC
the TextColor and StTB
the TextBackGround color.
StS
is a string wich defines what to output.
1st character is the Preamble reception.
2nd character is the Stream reception.
3rd character is the Interpretation.
Characters 4 to 18 are used to make a little ASCII animation.
Example:StS='rRI\\||//'
ShowTime
is a boolean wich defines if the unit shall output a clock. If set to true, TimX
, TiMY
, TimTC
and TimTB
defines the X and Y position, the Textcolor and the TextBackground of the clock.
COMPort
defines the RS232 port to use to send the POCSAG stream to. Any value between 1 and 4 is correct. The Unit found the real port address, so it's easy to use.
COMLine
defines the line to use in the COMPort. It could be $01 or $02. In the unit, DTR and RTS are predefined constant, so use it to define in wich line your HAMCOM interface inputs the stream.
Polarity
defines the way the unit shall code a bit. You have to find the good configuration for your HAMCOM interface.
Code
defines the way the Unit shall encode the message. If Beep, the message is ignored and only the RIC was sent. If Num, the message is encoded as numeric only, all characters outside the POCSAG correct numeric characters are sent as
spaces. If Alpha, the message is coded as alphanumeric.
Rate
defines the output stream speed, in BPS. You can select 512, 1200 or 2400 bps.
RIC
defines the RIC to send the message to. All corrects POCSAG RICs are possible.
FNCT
defines the function to send. You can select 0, 1, 2 or 3.
Mess
defines the message to send. You can define any message you want.
Note that characters over ASCII value 127 are send as '?'.