The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Device::TNC - A generic interface to a TNC

DESCRIPTION

This module implements a generic interface to a Terminal Node Controller (TNC).

It loads sub classes that provide the low level interface for the appropriate TNC to be used and provides higher level methods to return frames of data to the user is human readable form.

SYNOPSIS

  use Device::TNC;
  my $tnc_type = 'KISS';
  my %tnc_config = (
    'port' => ($Config{'osname'} eq "MSWin32") ? "COM3" : "/dev/TNC-X",
    'baudrate' => 9600,
    'warn_malformed_kiss' => 1,
    'raw_log' => "raw_packet.log",
  );
  my $tnc = new Device::TNC($tnc_type, %tnc_config);
  die "Error: Something went wrong connecting to the TNC.\n" unless $tnc;

  while (1)
  {
    my $data = $tnc->read_frame();
    my $repeaters = join ", ", @{$data->{'ADDRESS'}->{'REPEATERS'}};
    my $info = join "", @{$data->{'INFO'}};
    print "From: $data->{'ADDRESS'}->{'SOURCE'} ";
    print "To: $data->{'ADDRESS'}->{'DESTINATION'} ";
    print "via $repeaters\n";
    print "Data: $info\n";
  }

new()

 my $type = "KISS";
 my %tnc_data = { 'option' => 'value' };
 my $tnc = new Device::TNC($type, %tnc_data);

The new method creates and returns a new Device::TNC object that can be used to communicate with a Terminal Node Controller (TNC) of the type passed.

The method requires that the first passed argument be the type of TNC to connect to. This will try and load the appropriate module for the TNC type.

The subsequent options are passed to the module that is loaded to connect to the desired TNC.

For more details on these options see the module documentation for the TNC type.

read_frame()

 my $frame_data = $tnc->read_frame();
 my %frame_data = $tnc->read_frame();

This method reads a HDLC frame from the TNC and returns a structure as either a hash or a hash reference that contains the fields of the frame.

The structure of the returned data is like the following.

  {
    'INFO' => [
      '/', '0', '6', '4', '6', '5', '8', 'h', '3', '3', '5', '0', '.', '0', '0',
      'S', '\\', '1', '5', '1', '1', '2', '.', '0', '0', 'E', 'O', '2', '2', '6',
      '/', '0', '0', '0', '/', 'A', '=', '0', '0', '0', '1', '1', '1'
    ],
    'PID' => 'F0',
    'CONTROL' => {
      'POLL_FINAL' => 0,
      'FIELD_TYPE' => 'UI',
      'FRAME_TYPE' => 'U'
    },
    'ADDRESS' => {
      'DESTINATION' => 'APT311',
      'REPEATERS' => [
        'WIDE1-1',
        'WIDE2-2'
        ],
      'SOURCE' => 'VK2KFJ-7'
    }
  }

While developing this module I only received U (UI) type frames and so development of the code to work with I and S frames didn't really progress. If anyone want's to read I or S frames please let me know and I'll have a look at implementing them. Please create a KISS log of the data and email it to me.

SEE ALSO

 Device::TNC::KISS

AX.25 Link-Layer Protocol Specification http://www.tapr.org/pub_ax25.html

AUTHOR

R Bernard Davison <bdavison@asri.org.au>

COPYRIGHT

Copyright (C) 2007, Australian Space Research Institute.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.