Compiling PDL code

To compile a PDL, use the hcipdc command.

Store PDLs in the pdl directory, with a .pdl extension.

PDL basic style example
mlp_tcp.pdl
define driver tcpip-mlp;
version: “2.0”; 
end driver;
/* This driver manages the transmission of messages
* using the HL7 defined MLP protocol. Each message
* is bounded by a start character <0xb> and a stop
* string <0x1c><0xd>. 
*
* The phrase basic-msg recognizes this message 
* format.
* Once recognized, the message data will be 
* available from the ‘data’ field.
*/
define phrase basic-msg;
<vt>; field data = variable-array( not( <fs> ) );
<fs>;
<cr>;
end phrase;

/***************************************************************************** 
End of declarative section, TCL management functions start here.
 ******************************************************************************/
#{#
# This can be handled completely using the “basic”\ style.
hci_pd_msg_style basic phrase:basic-msg field:data\ 
                    resync:\0xb
Async PDL Example

#}# 
msmeds_async.pdl
define driver msmeds; 
version: “2.0”;
end driver;
/* This driver manages the transmission of messages * to the MSMeds system.
* Protocol Description:
*     Data Format: ASCII 
*     Character Format: 
*     Length: 1 start bit 
*             7 data bits 
*             1 stop bit 
* Parity: odd 
*
* Record Format: 
*     Start Text STX (ASCII 002, Hex 0x02) 
*     Text 
*     End of Text ETB (ASCII 027, Hex 0x17) 
*     BCC 3 ASCII characters (see below for 
*     calculation) 
*     End of Message ETX (ASCII 003, Hex 0x03) 
*
* ACK/NAK: ACK (ASCII 006, Hex 0x06 ) 
* NAK (ASCII 025, Hex 0x15 ) 
*
* Timeout:		Wait 30 seconds for ACK, then timeout 
*
* The BCC calculation is a modulo 128, performed by
* adding all characters from the Start of Text to 
* the End of Text inclusive. The resulting unsigned * value is then divided by 128 and the remaining 
* 8-bit quantity is converted to 3 ASCII digit 
* characters and added to the source message. 
*
* <stx><message text><etb><bcc1><bcc2><bcc3><etx> 
*
* o   If the message is ACK’ed, we are done 
* o   If the message is NAK’ed, mark message as NAK’ed
*       and return failure 
* o   If a timeout happens, mark message as timeout and
*       return failure
*/
define device; 
type:async; 
path:“/dev/tty1”; 
line-speed:9600; 
stop-bits:1; 
start-bits:1; 
data-bits:7; 
parity:odd; 
xon-xoff:disabled;
hw-flow-control:enabled;
require-cd:enabled;
end device;
/*Define the basic message structure. Set up the bcc
* calculation to include the <stx>, data, and <etb>
* characters. 
*
* BCC calculations are handled using a PDL concept
* called a virtual field (in this case, phrase-
* check). Virtual fields are automatically
* constructed if you do not specify data for them in 
* the write operation. In this case it
* auto-calculates the BCC value and \ places it 
* into the BCC field.
*/
define phrase basic-msg; 
<stx>; 
phrase-check { method: xor, store-in: bcc } = 
begin 	 field data = variable-array( not(<etb>)); 	
end;
<etb>;
field bcc = fixed-array( 3, digit );
<etx>;
end phrase;
/* You must define each message you write/read as a
/* phrase. Define ACK and NAK.
*/
define phrase ack-msg;
<ack>;
end phrase;
define phrase nak-msg;
<nak>;
end phrase;
/* Define a phrase for ignoring inbound data */
define phrase any-byte;
field junk = fixed-array( 1, any );
end phrase;
/***************************************************************************** 
End of declarative section, TCL management functions start here. 
******************************************************************************/
#{#
hci_pd_msg_style acknak phrase:basic-msg \
field:data        \
ackphrase:ack-msg \
nakphrase:nak-msg \
timeout:10000     \
naktries:3        \
tmotries:3
#}#