#!/usr/bin/perl -w
#
#Thanks Dave(W1HKJ) for your help - Tim KC4UMS
#
#Save all of this with the name "ipc_rcv.pl"
#From your shell type "chmod 777 ipc_rcv.pl"
#Run from the shell by typing "./ipc_rcv.pl"
#Log entry from gMFSK will display the fields in the shell
#
#This is the output after running the ipcs command from the shell
#With gMFSK running key 0x000004d6 decimal 1238 is the queue for gMFSK
#
#------ Message Queues --------
#key msqid owner perms used-bytes messages
#0x000004d6 753664 kc4ums 666 0 0
#
use IPC::SysV qw(IPC_PRIVATE IPC_RMID IPC_CREAT S_IRWXU);
#intialize the id same as msqid above to -1
$id = -1;
# Connect to the queue or create one(gMFSK not running)
my $id = msgget(1238,0666|IPC_CREAT);
# If $id is not a -1 we are ok
if ($id != -1)
{
print "Press CTL-C to terminate \n \n ";
# start a loop to receive mesaages
while(){
msgrcv($id, $rcvd, 1200, 0, 0) || die "Error queue $id";
# Split the string into an array by the "\1" character
@rcvd = split("\1",$rcvd,100);
print "$rcvd[0] \n"; #Xprogram
print "$rcvd[1] \n"; #version
print "$rcvd[2] \n"; #date
print "$rcvd[3] \n"; #time
print "$rcvd[4] \n"; #endtime
print "$rcvd[5] \n"; #call
print "$rcvd[6] \n"; #mhz
print "$rcvd[7] \n"; #mode
print "$rcvd[8] \n"; #tx
print "$rcvd[9] \n"; #rx
print "$rcvd[10] \n"; #name
print "$rcvd[11] \n"; #qth
print "$rcvd[12] \n"; #locator
print "$rcvd[13] \n"; #notes
print "\n\n";
};
};