- 论坛徽章:
- 0
|
本帖最后由 ykredrum 于 2010-03-13 23:00 编辑
想用个小程序,由电脑控制手机发短信,以前在论坛上找到过例子,稍微改了下
手机:Nokia 6300
——————————————————————————————————————————————
代码如下:
use strict;
use Device::Gsm;
my $pin = '0000';
my $gsm = new Device::Gsm( port => 'COM4', pin => $pin,log => 'file,send.log' );
die "cannot create Device::Gsm object!" unless $gsm;
$gsm->connect( baudrate => 19200 ) or die "cannot connect to GSM device on [COM4\]\n";
$gsm->register() or die "cannot register on GSM network: check pin and/or network signal!";
print "\nok! connected and registered to network.\n";
my $lOk = $gsm->send_sms(
content => 'hello world' ,
recipient => 'xxxxxxxxx', #接收短息的手机号码
status_report=>1,
);
if($lOk){
print "successful!/n";
}else{
print "failed!/n";
}
————————————————————————————————————————————
程序运行后出现错误,具体如下:
E:\>perl yk.pl
Missing REQUIRED setting for BAUD at D:/strawberry/perl/site/lib/Device/Modem.pm
line 506
write_settings failed, closing port at D:/strawberry/perl/site/lib/Device/Modem.
pm line 506
Missing REQUIRED setting for BAUD at D:/strawberry/perl/site/lib/Device/Modem.pm
line 506
write_settings failed, closing port at D:/strawberry/perl/site/lib/Device/Modem.
pm line 506
cannot register on GSM network: check pin and/or network signal! at yk.pl line 1
4.
————————————————————————————————————————————
以前用天语的手机发送成功过,手机换了后就出现错误了
不知道怎么回事我设置了 baudrate => 19200
错误一直说我没有设置。
请哥哥姐姐帮帮忙!谢谢了先 |
|