NAME

Device::TNC - A module to talk 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_ax25_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_ax25_frame()

my $ax25_data = $tnc->read_ax25_frame();
my %ax25_data = $tnc->read_ax25_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 AX.25 frame.

The structure of the returned data is like the following.

{
  'INFO' => [
    '!', '3', '3', '5', '1', '.', '8', '9', 'S', 'U', '1', '5', '1', '1', '2',
    '.', '2', '2', 'E', '#', 'P', 'H', 'G', '5', '7', '5'
    ],
  'FCS' => '4345',
  'PID' => 'F0',
  'CONTROL' => {
    'POLL_FINAL' => 0,
    'FIELD_TYPE' => 'UI',
    'FRAME_TYPE' => 'U'
  },
  'ADDRESS' => {
    'DESTINATION' => 'APZ186',
    'REPEATERS' => [
      'TRACE3-3'
    ],
    'SOURCE' => 'VK2JPJ-1'
  }
}

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.

While the Frame Check Sequense is being read at the moment the code does not check that the received frame is valid.

I'd really love some one who knows about such things to implement a routine to check if the received frame is valid.

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.