File: get_time.pl

package info (click to toggle)
libdevice-gsm-perl 1.61-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 504 kB
  • sloc: perl: 3,264; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
#
# Short example of use for Device::Gsm class
# Get date and time from phone 

use strict;
use lib 'blib/arch';
use lib 'blib';
use Device::Gsm;

print "\nthis is get_time.pl\n";
print "This script tries to get your gsm date/time\n";

my $gsm = conn();

print "\nok! connected to gsm phone.\n";

if( my $time = $gsm->datetime() ) {
	print "Time of phone should be now $time (yy/mm/dd hh:mn:ss)\n";
} else {
	print "Failed to get time!\n";
}

# End






sub conn {
	my $port = $^O =~ /Win/ ? 'COM2' : '/dev/ttyS1';
	my $myport;
	print "Select your serial port [$port] : ";
	chomp( $myport = <STDIN> );
	$myport ||= $port;
	my $gsm = new Device::Gsm( port => $myport, log => 'file,get_time.log', loglevel=>'info' );
	die "cannot create Device::Gsm object!" unless $gsm;
	$gsm->connect( baudrate => 19200 ) or die "cannot connect to GSM device on [$myport]\n";
	return $gsm;
}