| 1 | # | ||
| 2 | # $Id$ | ||
| 3 | # | ||
| 4 | # network::s7comm Brik | ||
| 5 | # | ||
| 6 | package Metabrik::Network::S7comm; | ||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use base qw(Metabrik::Client::Tcp); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | sub brik_properties { | ||
| 13 | return { | ||
| 14 | revision => '$Revision$', | ||
| 15 | tags => [ qw(unstable) ], | ||
| 16 | author => 'GomoR <GomoR[at]metabrik.org>', | ||
| 17 | license => 'http://opensource.org/licenses/BSD-3-Clause', | ||
| 18 | commands => { | ||
| 19 | probe => [ qw(host port|OPTIONAL) ], | ||
| 20 | }, | ||
| 21 | }; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub probe { | ||
| 25 | my $self = shift; | ||
| 26 | my ($host, $port) = @_; | ||
| 27 | |||
| 28 | $host ||= $self->host; | ||
| 29 | $port ||= 102; | ||
| 30 | $self->brik_help_run_undef_arg('probe', $host) or return; | ||
| 31 | |||
| 32 | # To port 102/TCP (from plcscan) | ||
| 33 | my $probe = | ||
| 34 | "\x03\x00\x00\x16\x11\xe0\x00\x00". | ||
| 35 | "\x00\x0b\x00\xc1\x02\x01\x00\xc2". | ||
| 36 | "\x02\x01\x02\xc0\x01\x0a"; | ||
| 37 | |||
| 38 | $self->host($host); | ||
| 39 | $self->port($port); | ||
| 40 | $self->connect or return; | ||
| 41 | $self->write($probe) or return; | ||
| 42 | my $response = $self->read or return; | ||
| 43 | $self->disconnect; | ||
| 44 | |||
| 45 | return $response; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; | ||
| 49 | |||
| 50 | __END__ | ||