Loading ...
Sorry, an error occurred while loading the content.

RE: [BPQ32] KIss mode with PK232

Expand Messages
  • Richard
    I wrote two Perl scripts for Linux to automatically set up my two TNC s - a PK-232 and a MFJ-1270B TNC into KISS mode - also the PK-232 is set to HF 300 baud
    Message 1 of 6 , Jun 3, 2013
    • 0 Attachment

      I wrote two Perl scripts for Linux to automatically set up my two TNC’s - a PK-232 and a MFJ-1270B TNC  into KISS mode – also the PK-232 is set to HF 300 baud and the MFJ is set to VHF 1200 baud … One needs to just change the $mycall from “ZS0MEE” to “YOURCALL” in each script, also change to your relevant COM ttyS? port(s) … The PC to TNC baudrate is set to 9600, which can be changed if desired .. The PC to TNC COM cable needs 8-wires to communicate – if you don’t use handshaking you could get away with 3-wires in the cable, but in my opinion, I prefer having hard handshaking ..

       

      The scripts below will figure out the current MFJ-1270B TNC mode and place the TNC into KISS mode and respective baud rate for either HF (PK-232) or VHF (MFJ), if it is not there already …

       

      There are ‘sleep’ commands throughout each script – this is to allow the TNC’s to respond to each command properly – preferably don’t fiddle with them ..

       

      The scripts can be run manually from a terminal but best is to start the two scripts from your start-up LinBPQ file …..

       

      Before running these scripts, run ‘install Device::SerialPort’ from CPAN in a terminal – this module is required for the scripts to work ..

       

      73, Dick ZS6RO

       

      Filename = kiss_on_tnc_mfj.pl

      ==========================

       

      #!/usr/bin/perl

      #

      # /home/linbpq/kiss_on_tnc_mfj.pl

      #

      # Script to figure out the current MFJ-1270B TNC mode and place

      # TNC into VHF 1200 baud and into KISS mode if it is not there.

      #

      # Version 1.0 Dick ZS6RO  21 January 2013.

       

      use strict;

      use warnings;

      use Device::SerialPort;

       

      my ($count, $result, $cmdflag);

      my $mycall = "ZS0MEE\r";              # Change to your BBS callsign.

      my $reset = "RESET\r";

      my $kisson = "KISS ON\r";

      my $restart = "RESTART\r";

       

      my $PortObj=Device::SerialPort->new("/dev/ttyS6");   # Change to relevant ttyS? serial Port.

       

      # set PC to TNC COM parameters to '9600, 8-bits, no-parity, 1-stop bit' and RTS hard handshake.

      $PortObj->baudrate(9600);

      $PortObj->parity("none");

      $PortObj->databits(8);

      $PortObj->stopbits(1);

      $PortObj->handshake("rts");

      $PortObj->write_settings;

       

      $PortObj->read_char_time(0);

      $PortObj->read_const_time(100);

       

      # iterate up to 5 times looking for the command prompt

      # in case there's lots more in the buffer to read out.

      $count = 5;

      $cmdflag = 0;

      while ($count > 0)  {

        $PortObj->write("\r");

        sleep (1);

        $result = $PortObj->read(255);

        print "\n*** $count - Reading TNC Data...\n";

        if ($result =~ m/cmd:/)  {

          $cmdflag = 1;

          $count = 0;

        } else {

          print "*** $count - First try and reset the TNC if in command mode.\n";

          $PortObj->write($reset);

          sleep(1);

          $count = $count - 1;

        }

      }

       

      if ($cmdflag == 1)  {

        print "\n*** OK - got the cmd prompt.\n\n";

      } else {

        #  check again and see if we can get command mode responses.

        print "\n*** Try and reset the TNC once again if in command mode.\n\n";

        $PortObj->write($reset);

        sleep(1);

        $PortObj->write("\r");

        sleep(1);

        $count = 5;

        while ($count > 0)  {

          # send commands to take TNC out of KISS MODE - at this point we don't know for sure

          # if its in KISS mode or not, but we know we're not getting expected responses for

          # normal command mode, so this will take it out of KISS if it's in that mode.

       

          print "*** No command prompt - sending commands to\n*** exit KISS mode in case that's the reason.\n\n";

       

          $PortObj->write(chr(192));

          $PortObj->write(chr(255));

          $PortObj->write(chr(192));

          sleep(1);

       

          $PortObj->write("\r");

          sleep(1);

       

          $result = $PortObj->read(255);

          sleep(1);

       

          print "*** $count - Reading TNC data after sending commands to exit KISS mode...\n";

          print "$result\n";

          if ($result =~ m/cmd:/)  {

            $cmdflag = 2;

            $count = 0;

            print "\n*** OK, got expected command prompt.\n\n";

          } else {

            $count = $count - 1;

          }

        }

      }

       

      if ($cmdflag == 0)  {

        print "\n*** Was not able to communicate with TNC.\n\n";

      }

       

      if ($cmdflag > 0)  {

        print "*** Place TNC into KISS mode. Please wait .....\n\n";

        # if there is a command prompt, put the TNC in KISS mode.

        $PortObj->write($kisson);

        sleep(1);

        $result = $PortObj->read(255);

        print "$result\n";

        $PortObj->write($restart);

        sleep(1);

        $result = $PortObj->read(255);

        print "$result\n";

        print "\n*** TNC is now in KISS mode.\n\n";

      }

      $PortObj->close;

       

      exit 0;

       

      # -- End of script.

      #

       

      Filename= kiss_on_tnc_pk232.pl

      ===========================

       

      #!/usr/bin/perl

      #

      # /home/linbpq/kiss_on_tnc_pk232.pl

      #

      # Script to figure out the current MFJ-1270B TNC mode and place

      # into HF 300 baud and KISS mode if it is not there.

      #

      # Version 1.0 Dick ZS6RO  21 January 2013.

       

      use strict;

      use warnings;

      use Device::SerialPort;

       

      my ($count, $result, $cmdflag);

      my $reset = "RESET\r";

      my $mycall = "ZS0MEE\r";             # Change to your BBS callsign.

      my $hb300 = "HB 300\r";

      my $vhfoff = "VHF OFF\r";

      my $restart = "RESTART\r";

      my $conmodetrans = "CONM TRANS\r";

      my $rawhon = "RAWH ON\r";

      my $hpolloff = "HPOLL OFF\r";

      my $kisson = "KISS ON\r";

      my $hoston = "HOST ON\r";

       

      my $PortObj=Device::SerialPort->new("/dev/ttyS7");  # Change to relevant ttyS? serial Port.

       

      #  set PC to TNC COM parameters to '9600, 8-bits, no-parity, 1-stop bit' and RTS hard handshake.

      $PortObj->baudrate(9600);

      $PortObj->parity("none");

      $PortObj->databits(8);

      $PortObj->stopbits(1);

      $PortObj->handshake("rts");

      $PortObj->write_settings;

       

      $PortObj->read_char_time(0);

      $PortObj->read_const_time(100);

       

      # iterate up to 5 times looking for the command prompt

      # in case there's lots more in the buffer to read out.

      $count = 5;

      $cmdflag = 0;

      while ($count > 0)  {

        $PortObj->write("*");

        sleep (1);

        $result = $PortObj->read(255);

        print "\n*** $count - Reading TNC Data...\n";

        if ($result =~ m/cmd:/)  {

          $cmdflag = 1;

          $count = 0;

        } else {

          print "*** First try and reset the TNC if in command mode.\n";

          $PortObj->write($reset);

          sleep(1);

          $count = $count - 1;

        }

      }

       

      # print "cmdflag = $cmdflag\n\n";

      if ($cmdflag == 1)  {

        print "\n*** OK - got the cmd prompt.\n\n";

      } else {

        #  check again and see if we can get command mode reponses.

        print "\n*** Try and reset the TNC once more if in command mode.\n\n";

        $PortObj->write($reset);

        sleep(1);

        $PortObj->write("\r");

        sleep(1);

        $count = 5;

        print "\n";

        while ($count > 0)  {

          # send commands to take TNC out of KISS MODE - at this point we don't know for sure

          # if its in KISS mode or not, but we know we're not getting expected responses for

          # normal command mode, so this will take it out of KISS if it's in that mode.

       

          print "*** No command prompt - sending commands to\n*** exit KISS mode in case that's the reason.\n\n";

       

          $PortObj->write(chr(192));

          $PortObj->write(chr(255));

          $PortObj->write(chr(192));

       

          sleep(1);

          $PortObj->write("\r");

          sleep(1);

          $result = $PortObj->read(255);

          sleep(1);

          print "*** $count - Reading TNC data after sending commands to exit KISS mode...";

          print "$result\n";

          if ($result =~ m/cmd:/)  {

            $cmdflag = 2;

            $count = 0;

            print "\n*** OK, got expected command prompt.\n\n";

          } else {

          $count = $count - 1;

          }

        }

      }

       

      if ($cmdflag == 0)  {

        print "\n*** Was not able to communicate with TNC.\n\n";

      }

       

      if ($cmdflag > 0)  {

        print "*** Place TNC into KISS mode.\n\n";

        # if there is a command prompt, put the TNC in KISS mode.

        $PortObj->write($mycall);

        sleep(1);

        $PortObj->write($hb300);

        sleep(1);

        $PortObj->write($vhfoff);

        sleep(1);

        $PortObj->write($restart);

        sleep(3);

        $PortObj->write($conmodetrans);

        sleep(1);

        $PortObj->write($rawhon);

        sleep(1);

        $PortObj->write($hpolloff);

        sleep(1);

        $PortObj->write($kisson);

        sleep(1);

        $PortObj->write($hoston);

        sleep(1);

        $result = $PortObj->read(255);

        print "$result\n";

        $result = $PortObj->read(255);

        print "$result\n";

        print "\n*** TNC is now in KISS mode.\n\n";

      }

      $PortObj->close;

       

      exit 0;

       

      # -- End of script.

      #

       

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

       

      From: BPQ32@yahoogroups.com [mailto:BPQ32@yahoogroups.com] On Behalf Of Dave
      Sent: 02 June 2013 23:50
      To: BPQ32@yahoogroups.com
      Subject: Re: [BPQ32] KIss mode with PK232

       

      I have to do the same with old MFJ TNC2
      Dave
      WB2HVF

      >

      >
      >
      Bruce, I have only been able to get a PK232 into a valid kiss mode by
      hand. No program that claims to work actually has, for me. I use a dumb
      terminal and simply issue a kiss on command. Then start bpq. Have you
      tried that?

      Mark

    • nl2prc
      Hi one remark You have to open CPAN first with command ( perl -MCPAN -e shell ) Before you can give command ( install Device::SerialPort ) Maybe its also
      Message 2 of 6 , Jun 4, 2013
      • 0 Attachment
        Hi

        one remark
        You have to open CPAN first with command ( perl -MCPAN -e shell )

        Before you can give command ( install Device::SerialPort )

        Maybe its also better that you make this files in a attachment

        When i made a copy there are a lot of ^M in the file's

        73, ascal


        --- In BPQ32@yahoogroups.com, "Richard" <yahoolist@...> wrote:
        >
        > I wrote two Perl scripts for Linux to automatically set up my two TNC's - a
        > PK-232 and a MFJ-1270B TNC into KISS mode - also the PK-232 is set to HF
        > 300 baud and the MFJ is set to VHF 1200 baud . One needs to just change the
        > $mycall from "ZS0MEE" to "YOURCALL" in each script, also change to your
        > relevant COM ttyS? port(s) . The PC to TNC baudrate is set to 9600, which
        > can be changed if desired .. The PC to TNC COM cable needs 8-wires to
        > communicate - if you don't use handshaking you could get away with 3-wires
        > in the cable, but in my opinion, I prefer having hard handshaking ..
        >
        >
        >
        > The scripts below will figure out the current MFJ-1270B TNC mode and place
        > the TNC into KISS mode and respective baud rate for either HF (PK-232) or
        > VHF (MFJ), if it is not there already .
        >
        >
        >
        > There are 'sleep' commands throughout each script - this is to allow the
        > TNC's to respond to each command properly - preferably don't fiddle with
        > them ..
        >
        >
        >
        > The scripts can be run manually from a terminal but best is to start the two
        > scripts from your start-up LinBPQ file ...
        >
        >
        >
        > Before running these scripts, run 'install Device::SerialPort' from CPAN in
        > a terminal - this module is required for the scripts to work ..
        >
        >
        >
        > 73, Dick ZS6RO
        >
        >
        >
        > Filename = kiss_on_tnc_mfj.pl
        >
        > ==========================
        >
        >
        >
        > #!/usr/bin/perl
        >
        > #
        >
        > # /home/linbpq/kiss_on_tnc_mfj.pl
        >
        > #
        >
        > # Script to figure out the current MFJ-1270B TNC mode and place
        >
        > # TNC into VHF 1200 baud and into KISS mode if it is not there.
        >
        > #
        >
        > # Version 1.0 Dick ZS6RO 21 January 2013.
        >
        >
        >
        > use strict;
        >
        > use warnings;
        >
        > use Device::SerialPort;
        >
        >
        >
        > my ($count, $result, $cmdflag);
        >
        > my $mycall = "ZS0MEE\r"; # Change to your BBS callsign.
        >
        > my $reset = "RESET\r";
        >
        > my $kisson = "KISS ON\r";
        >
        > my $restart = "RESTART\r";
        >
        >
        >
        > my $PortObj=Device::SerialPort->new("/dev/ttyS6"); # Change to relevant
        > ttyS? serial Port.
        >
        >
        >
        > # set PC to TNC COM parameters to '9600, 8-bits, no-parity, 1-stop bit' and
        > RTS hard handshake.
        >
        > $PortObj->baudrate(9600);
        >
        > $PortObj->parity("none");
        >
        > $PortObj->databits(8);
        >
        > $PortObj->stopbits(1);
        >
        > $PortObj->handshake("rts");
        >
        > $PortObj->write_settings;
        >
        >
        >
        > $PortObj->read_char_time(0);
        >
        > $PortObj->read_const_time(100);
        >
        >
        >
        > # iterate up to 5 times looking for the command prompt
        >
        > # in case there's lots more in the buffer to read out.
        >
        > $count = 5;
        >
        > $cmdflag = 0;
        >
        > while ($count > 0) {
        >
        > $PortObj->write("\r");
        >
        > sleep (1);
        >
        > $result = $PortObj->read(255);
        >
        > print "\n*** $count - Reading TNC Data...\n";
        >
        > if ($result =~ m/cmd:/) {
        >
        > $cmdflag = 1;
        >
        > $count = 0;
        >
        > } else {
        >
        > print "*** $count - First try and reset the TNC if in command mode.\n";
        >
        > $PortObj->write($reset);
        >
        > sleep(1);
        >
        > $count = $count - 1;
        >
        > }
        >
        > }
        >
        >
        >
        > if ($cmdflag == 1) {
        >
        > print "\n*** OK - got the cmd prompt.\n\n";
        >
        > } else {
        >
        > # check again and see if we can get command mode responses.
        >
        > print "\n*** Try and reset the TNC once again if in command mode.\n\n";
        >
        > $PortObj->write($reset);
        >
        > sleep(1);
        >
        > $PortObj->write("\r");
        >
        > sleep(1);
        >
        > $count = 5;
        >
        > while ($count > 0) {
        >
        > # send commands to take TNC out of KISS MODE - at this point we don't
        > know for sure
        >
        > # if its in KISS mode or not, but we know we're not getting expected
        > responses for
        >
        > # normal command mode, so this will take it out of KISS if it's in that
        > mode.
        >
        >
        >
        > print "*** No command prompt - sending commands to\n*** exit KISS mode
        > in case that's the reason.\n\n";
        >
        >
        >
        > $PortObj->write(chr(192));
        >
        > $PortObj->write(chr(255));
        >
        > $PortObj->write(chr(192));
        >
        > sleep(1);
        >
        >
        >
        > $PortObj->write("\r");
        >
        > sleep(1);
        >
        >
        >
        > $result = $PortObj->read(255);
        >
        > sleep(1);
        >
        >
        >
        > print "*** $count - Reading TNC data after sending commands to exit KISS
        > mode...\n";
        >
        > print "$result\n";
        >
        > if ($result =~ m/cmd:/) {
        >
        > $cmdflag = 2;
        >
        > $count = 0;
        >
        > print "\n*** OK, got expected command prompt.\n\n";
        >
        > } else {
        >
        > $count = $count - 1;
        >
        > }
        >
        > }
        >
        > }
        >
        >
        >
        > if ($cmdflag == 0) {
        >
        > print "\n*** Was not able to communicate with TNC.\n\n";
        >
        > }
        >
        >
        >
        > if ($cmdflag > 0) {
        >
        > print "*** Place TNC into KISS mode. Please wait .....\n\n";
        >
        > # if there is a command prompt, put the TNC in KISS mode.
        >
        > $PortObj->write($kisson);
        >
        > sleep(1);
        >
        > $result = $PortObj->read(255);
        >
        > print "$result\n";
        >
        > $PortObj->write($restart);
        >
        > sleep(1);
        >
        > $result = $PortObj->read(255);
        >
        > print "$result\n";
        >
        > print "\n*** TNC is now in KISS mode.\n\n";
        >
        > }
        >
        > $PortObj->close;
        >
        >
        >
        > exit 0;
        >
        >
        >
        > # -- End of script.
        >
        > #
        >
        >
        >
        > Filename= kiss_on_tnc_pk232.pl
        >
        > ===========================
        >
        >
        >
        > #!/usr/bin/perl
        >
        > #
        >
        > # /home/linbpq/kiss_on_tnc_pk232.pl
        >
        > #
        >
        > # Script to figure out the current MFJ-1270B TNC mode and place
        >
        > # into HF 300 baud and KISS mode if it is not there.
        >
        > #
        >
        > # Version 1.0 Dick ZS6RO 21 January 2013.
        >
        >
        >
        > use strict;
        >
        > use warnings;
        >
        > use Device::SerialPort;
        >
        >
        >
        > my ($count, $result, $cmdflag);
        >
        > my $reset = "RESET\r";
        >
        > my $mycall = "ZS0MEE\r"; # Change to your BBS callsign.
        >
        > my $hb300 = "HB 300\r";
        >
        > my $vhfoff = "VHF OFF\r";
        >
        > my $restart = "RESTART\r";
        >
        > my $conmodetrans = "CONM TRANS\r";
        >
        > my $rawhon = "RAWH ON\r";
        >
        > my $hpolloff = "HPOLL OFF\r";
        >
        > my $kisson = "KISS ON\r";
        >
        > my $hoston = "HOST ON\r";
        >
        >
        >
        > my $PortObj=Device::SerialPort->new("/dev/ttyS7"); # Change to relevant
        > ttyS? serial Port.
        >
        >
        >
        > # set PC to TNC COM parameters to '9600, 8-bits, no-parity, 1-stop bit' and
        > RTS hard handshake.
        >
        > $PortObj->baudrate(9600);
        >
        > $PortObj->parity("none");
        >
        > $PortObj->databits(8);
        >
        > $PortObj->stopbits(1);
        >
        > $PortObj->handshake("rts");
        >
        > $PortObj->write_settings;
        >
        >
        >
        > $PortObj->read_char_time(0);
        >
        > $PortObj->read_const_time(100);
        >
        >
        >
        > # iterate up to 5 times looking for the command prompt
        >
        > # in case there's lots more in the buffer to read out.
        >
        > $count = 5;
        >
        > $cmdflag = 0;
        >
        > while ($count > 0) {
        >
        > $PortObj->write("*");
        >
        > sleep (1);
        >
        > $result = $PortObj->read(255);
        >
        > print "\n*** $count - Reading TNC Data...\n";
        >
        > if ($result =~ m/cmd:/) {
        >
        > $cmdflag = 1;
        >
        > $count = 0;
        >
        > } else {
        >
        > print "*** First try and reset the TNC if in command mode.\n";
        >
        > $PortObj->write($reset);
        >
        > sleep(1);
        >
        > $count = $count - 1;
        >
        > }
        >
        > }
        >
        >
        >
        > # print "cmdflag = $cmdflag\n\n";
        >
        > if ($cmdflag == 1) {
        >
        > print "\n*** OK - got the cmd prompt.\n\n";
        >
        > } else {
        >
        > # check again and see if we can get command mode reponses.
        >
        > print "\n*** Try and reset the TNC once more if in command mode.\n\n";
        >
        > $PortObj->write($reset);
        >
        > sleep(1);
        >
        > $PortObj->write("\r");
        >
        > sleep(1);
        >
        > $count = 5;
        >
        > print "\n";
        >
        > while ($count > 0) {
        >
        > # send commands to take TNC out of KISS MODE - at this point we don't
        > know for sure
        >
        > # if its in KISS mode or not, but we know we're not getting expected
        > responses for
        >
        > # normal command mode, so this will take it out of KISS if it's in that
        > mode.
        >
        >
        >
        > print "*** No command prompt - sending commands to\n*** exit KISS mode
        > in case that's the reason.\n\n";
        >
        >
        >
        > $PortObj->write(chr(192));
        >
        > $PortObj->write(chr(255));
        >
        > $PortObj->write(chr(192));
        >
        >
        >
        > sleep(1);
        >
        > $PortObj->write("\r");
        >
        > sleep(1);
        >
        > $result = $PortObj->read(255);
        >
        > sleep(1);
        >
        > print "*** $count - Reading TNC data after sending commands to exit KISS
        > mode...";
        >
        > print "$result\n";
        >
        > if ($result =~ m/cmd:/) {
        >
        > $cmdflag = 2;
        >
        > $count = 0;
        >
        > print "\n*** OK, got expected command prompt.\n\n";
        >
        > } else {
        >
        > $count = $count - 1;
        >
        > }
        >
        > }
        >
        > }
        >
        >
        >
        > if ($cmdflag == 0) {
        >
        > print "\n*** Was not able to communicate with TNC.\n\n";
        >
        > }
        >
        >
        >
        > if ($cmdflag > 0) {
        >
        > print "*** Place TNC into KISS mode.\n\n";
        >
        > # if there is a command prompt, put the TNC in KISS mode.
        >
        > $PortObj->write($mycall);
        >
        > sleep(1);
        >
        > $PortObj->write($hb300);
        >
        > sleep(1);
        >
        > $PortObj->write($vhfoff);
        >
        > sleep(1);
        >
        > $PortObj->write($restart);
        >
        > sleep(3);
        >
        > $PortObj->write($conmodetrans);
        >
        > sleep(1);
        >
        > $PortObj->write($rawhon);
        >
        > sleep(1);
        >
        > $PortObj->write($hpolloff);
        >
        > sleep(1);
        >
        > $PortObj->write($kisson);
        >
        > sleep(1);
        >
        > $PortObj->write($hoston);
        >
        > sleep(1);
        >
        > $result = $PortObj->read(255);
        >
        > print "$result\n";
        >
        > $result = $PortObj->read(255);
        >
        > print "$result\n";
        >
        > print "\n*** TNC is now in KISS mode.\n\n";
        >
        > }
        >
        > $PortObj->close;
        >
        >
        >
        > exit 0;
        >
        >
        >
        > # -- End of script.
        >
        > #
        >
        >
        >
        > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        >
        >
        >
        > From: BPQ32@yahoogroups.com [mailto:BPQ32@yahoogroups.com] On Behalf Of Dave
        > Sent: 02 June 2013 23:50
        > To: BPQ32@yahoogroups.com
        > Subject: Re: [BPQ32] KIss mode with PK232
        >
        >
        >
        > I have to do the same with old MFJ TNC2
        > Dave
        > WB2HVF
        >
        > >
        >
        > >
        > >
        > Bruce, I have only been able to get a PK232 into a valid kiss mode by
        > hand. No program that claims to work actually has, for me. I use a dumb
        > terminal and simply issue a kiss on command. Then start bpq. Have you
        > tried that?
        >
        > Mark
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.