Je viens d'avoir un myX6-2
et vu que je n'ai que mon vieux cable série pour les transférer vers mon PC arrive le problème
MPAS m'affiche un message d'erreur si jamais je veux récupérer plus d'une image a la fois sur mon téléphone
et c'est super lourd. (surtout que je travaille normalement sous linux donc MPAS déjà a la base c'est galère)
Donc j'ai trouvé un petit script perl qui s'appelle getpic (le lien est ici)
écrit a l'époque pour un myX5-2
cool
mais au départ il marchait pas comme il faut pour le myX6 puisqu'il récupérait l'icone de la taille de l'écran du portable :
176x220 ...pas terrible.
donc j'ai un peu modifier le script et maintenant il récupère les images en taille normale (1024*1280)....mais pas toujours !!!!!
en effet pour certaines images et uniquement de temps en temps, d'après ce que j'ai eu le temps de tester le transfert merde sur la fin et le fichiers n'est pas lisible. (genre il fait un octet de plus que le fichier correct, c'est ballot
En meme temps j'ai fait ca un peu n'importe comment donc,
si quelqu'un peu m'aider ou sait ou je peux trouver des infos ?
merci.
je sais pas ou mettre le script alors j'ai fait un petit copier-coller ici :
CODE
#!/usr/bin/perl -w
###############################################################################
# getpic copyright 2004, Sharp (sharpy+at+xox.pl)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Full license text: http://www.gnu.org/licenses/gpl.txt
###############################################################################
use Getopt::Std;
my( $out, $port); # buffer, port handle.
my( $i, $j); # helpful indexes.
my ($id,$hidden,$len,$category,$content,
$location,$flag,$descstr,$name); # Object list structure
my %names; # Filename/ID of object hash
my @spis; # Object list
my $windows=0;
# port, baudrate, filename, delete, no_bklist
our ($opt_p,$opt_b,$opt_f,$opt_x,$opt_B,$opt_v,$opt_V,$opt_h,$opt_X,$opt_l);
# JPEG header. Only 3 bytes because 4th byte is non-standard in MyX5-2
my $header = "\xff\xd8\xff";
my $endOfImage = "\xff\xd9";
BEGIN {
if ($^O eq "MSWin32"){ $windows=1;}
if ($windows) {
eval "use Win32::SerialPort";
if ($@){die();}
} else {
eval "use Device::SerialPort";
if ($@){die();}
}
}
# Copyrighted undownloadable files.
my $blacklist= " Aureole Boredom Bow tie Broken heart Bucolic Bucolic1 Bucolic2 Cat Clown Coast Colleagues Crown Customers Dream Elephant Era Exclamation Fabric Family Film Flower Flower Friends Happiness Heart Idea Lagoons Leaf Leisures Lightning Love Mountain Moustache Question Rose Sadness Sky Stamp Stars Swearwords Tear Theatre Tribal TV VIP Zzz ";
# myX6-2
#my $blacklist= "Test Weave Cabin Cat Cheeky Disco 41 Duck Eyes Fanny Flet Flow Galaxy Glow Hearpiece Hills Hurican juju Madame Mouton2 Marie et Lena Marion Mosaic Music Orange Disco Photo 0009 Photo 0010 Photo 0016 Photo 0012 Photo 0018 Photo 0021 Pierre Planet Spiral Star Stroke Sun Wash Flower Weave";
# Parse commandline options
$Getopt::Std::STANDARD_HELP_VERSION=1;
getopts('p:b:f:xXBvVhl');
if($opt_h){HELP_MESSAGE();}
if($opt_v or $opt_V){VERSION_MESSAGE();}
select((select(STDOUT), $| = 1)[0]); # unbuffer STDOUT to enable progress disp.
if(!$opt_b){$opt_b=115200;}
if(!$opt_p){
if($windows){ $opt_p="COM1";} else { $opt_p="/dev/ttyS1";}
}
# Init serial port
if ($windows) {
$port = new Win32::SerialPort($opt_p) || die("Can't open port!");
}
else {
$port = new Device::SerialPort($opt_p) || die("Can't open port!");
}
$port->baudrate($opt_b);
$port->databits(8);
$port->stopbits(2);
$port->parity("none");
$i=10;
sleep(1);
print "\nConnecting...\n";
# Send "Reset", retry 10 times answer other than OK, 100 times total.
while($i){
$i--;
$_ = snd('ATZ');
print ".";
if(/OK/){$i=0;}
}
if(!/OK/){die("\nCan't connect\n");}
# Send "Set Charset", retry 10 times answer other than OK, 100 times total.
$i=10;
print "\nSetting charset...\n";
while($i){
$i--;
$_ = snd('AT+CSCS="8859-1"');
if(/OK/){$i=0;}
}
if(!/OK/){die("\nCan't set charset...\n");}
$i = 0;
print "\nRetrieving list...\n";
# Data is multi-line so we can't fail on first lack of OK.
# Some timeouts are allowed as well...
# Instead we fail after 50 timeouts in a row.
$out = snd('AT+KPSL="PICTURES",1');
do {
$_ = $port->input;
if($_ eq ''){
select(undef,undef,undef,0.1);
print " ";
$i++;
} else {
$out .= $_;
$i=0;
print ".";
}
} while ( !($out =~ /\nOK\r$/) && $i<50);
if( $i>=50){die("\nTimeout while retrieving list\n");}
# parse the list. First, split it on CRLF into lines.
@spis = split /\r\n/,$out;
print "\nFound pictures:\n";
foreach(@spis){
chomp;
# Comma-separated list. Only $id and $name is in use currently.
($id,$hidden,$len,$category,$content,
$location,$flag,$name)=split /,/i,$_,8;
# Dump all non-list lines.
next if !$name;
# Strip the "+KPSL: " invocation from first entry
(undef,$id)=split / /,$id;
# Strip quotes from filename
$name =~ s/^"(.*)"$/$1/g;
next if ( !$opt_B && ($blacklist =~ /\s$name\s/));
next if ( $opt_f && !($name =~ /${opt_f}/) );
$names{$name}=$id;
print "$name ";
}
end() if $opt_l;
# Grab all files...
if(!$opt_X) {
foreach(keys(%names)){
$name=$_;
print "\nretrieving $name...\n";
$i=0;
$out = snd('AT+KPSR='.$names{$name}); # Retrieve by ID.
# Rest of multi-line content
do {
$_ = $port->input;
if($_ eq ''){
select(undef,undef,undef,0.1);
print " ";
$i++;
} else {
$out .= $_;
$i=0;
print ".";
}
} while ( ! ($out =~ /\nNO CARRIER\r$/) && $i<50);
# 30s timeout total, giving up on this file,
# still chance the next one will be OK
if( $i>=50){print ("\nError retrieving $name\n"); next;}
print "\nExtracting...";
# Extract the second (and last) JPEG from the data retrieved.
# on my "myX6-2" phone the second header is missing
$out =~ m/$header.+?($endOfImage.+)\s+NO CARRIER/s;
$out = $1;
$out =~ s/$endOfImage/$header/i;
# $name = quotemeta($name);
print "writing...";
open(FILE,">$name.jpg");
print FILE $out;
close(FILE);
print "done.\n";
} # foreach name
} # if opt_X
# Delete files.
if($opt_X || $opt_x) {
foreach(keys(%names)){
$name = $_;
print "\nDeleting $name...\n";
$i=40; $out='';
$port->write("AT+KPSD=$names{$name}\r\n"); # Delete by ID.
do {
$out .= $port->input;
select(undef,undef,undef,0.5); # sleep 0.1s
print " .";
$i--;
if(($i>2) && ($out ne '')){$i=2;}
} while($i);
if($out =~ /OK/) { print "\nOK\n";} else {print "\nFailed\n";}
} # foreach name
} # if opt_Xx.
end();
# end of main
############################################################################
# subroutines.
# Send $snd, retry 10 times, for each retry wait 1s for answer.
sub snd
{
my($snd,$rec,$t,$j);
$snd=shift;
$t=10; # 10 resend retries
while($t){
$port->write("$snd\r\n");
$j=10;
$t--;
while ($j){
$j--;
$rec = $port->input;
if ( $rec ne '' ){
print ".";
return $rec;
}
select(undef,undef,undef,0.1); # sleep 0.1s
print " ";
} # Timeout
} # Retries
die("Timeout: No reply to $snd")
} # sub snd
sub VERSION_MESSAGE
{
if($opt_V){
print "
GETPIC
version 0.1b by Sharp '2004 (sharpy".'@'."xox.pl)
Picture downloader for Sagem Myx5-2
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Full license text: http://www.gnu.org/licenses/gpl.txt
";
} else {
print "getpic 0.1b";
}
end();
}
sub HELP_MESSAGE
{
print "
Usage:
getpic - use default settings, download all pictures
getpic -f regex - download all pictures matching regex
-p /dev/ttySn - use /dev/ttySn as port device (default ttyS0)
-b num - use num as baudrate (default 115200)
-l - list matching files only (then quit)
-B - skip blacklist matching (try copyrighted pics too)
-x - delete remote files after downloading
-X - delete remote files WITHOUT downloading
-h or --help - this help
-v or --version - version (brief)
-V - version and license
";
exit(0);
}
sub end
{
print "\n";
$port->close() if $port;
exit(0);
}
###############################################################################
# getpic copyright 2004, Sharp (sharpy+at+xox.pl)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Full license text: http://www.gnu.org/licenses/gpl.txt
###############################################################################
use Getopt::Std;
my( $out, $port); # buffer, port handle.
my( $i, $j); # helpful indexes.
my ($id,$hidden,$len,$category,$content,
$location,$flag,$descstr,$name); # Object list structure
my %names; # Filename/ID of object hash
my @spis; # Object list
my $windows=0;
# port, baudrate, filename, delete, no_bklist
our ($opt_p,$opt_b,$opt_f,$opt_x,$opt_B,$opt_v,$opt_V,$opt_h,$opt_X,$opt_l);
# JPEG header. Only 3 bytes because 4th byte is non-standard in MyX5-2
my $header = "\xff\xd8\xff";
my $endOfImage = "\xff\xd9";
BEGIN {
if ($^O eq "MSWin32"){ $windows=1;}
if ($windows) {
eval "use Win32::SerialPort";
if ($@){die();}
} else {
eval "use Device::SerialPort";
if ($@){die();}
}
}
# Copyrighted undownloadable files.
my $blacklist= " Aureole Boredom Bow tie Broken heart Bucolic Bucolic1 Bucolic2 Cat Clown Coast Colleagues Crown Customers Dream Elephant Era Exclamation Fabric Family Film Flower Flower Friends Happiness Heart Idea Lagoons Leaf Leisures Lightning Love Mountain Moustache Question Rose Sadness Sky Stamp Stars Swearwords Tear Theatre Tribal TV VIP Zzz ";
# myX6-2
#my $blacklist= "Test Weave Cabin Cat Cheeky Disco 41 Duck Eyes Fanny Flet Flow Galaxy Glow Hearpiece Hills Hurican juju Madame Mouton2 Marie et Lena Marion Mosaic Music Orange Disco Photo 0009 Photo 0010 Photo 0016 Photo 0012 Photo 0018 Photo 0021 Pierre Planet Spiral Star Stroke Sun Wash Flower Weave";
# Parse commandline options
$Getopt::Std::STANDARD_HELP_VERSION=1;
getopts('p:b:f:xXBvVhl');
if($opt_h){HELP_MESSAGE();}
if($opt_v or $opt_V){VERSION_MESSAGE();}
select((select(STDOUT), $| = 1)[0]); # unbuffer STDOUT to enable progress disp.
if(!$opt_b){$opt_b=115200;}
if(!$opt_p){
if($windows){ $opt_p="COM1";} else { $opt_p="/dev/ttyS1";}
}
# Init serial port
if ($windows) {
$port = new Win32::SerialPort($opt_p) || die("Can't open port!");
}
else {
$port = new Device::SerialPort($opt_p) || die("Can't open port!");
}
$port->baudrate($opt_b);
$port->databits(8);
$port->stopbits(2);
$port->parity("none");
$i=10;
sleep(1);
print "\nConnecting...\n";
# Send "Reset", retry 10 times answer other than OK, 100 times total.
while($i){
$i--;
$_ = snd('ATZ');
print ".";
if(/OK/){$i=0;}
}
if(!/OK/){die("\nCan't connect\n");}
# Send "Set Charset", retry 10 times answer other than OK, 100 times total.
$i=10;
print "\nSetting charset...\n";
while($i){
$i--;
$_ = snd('AT+CSCS="8859-1"');
if(/OK/){$i=0;}
}
if(!/OK/){die("\nCan't set charset...\n");}
$i = 0;
print "\nRetrieving list...\n";
# Data is multi-line so we can't fail on first lack of OK.
# Some timeouts are allowed as well...
# Instead we fail after 50 timeouts in a row.
$out = snd('AT+KPSL="PICTURES",1');
do {
$_ = $port->input;
if($_ eq ''){
select(undef,undef,undef,0.1);
print " ";
$i++;
} else {
$out .= $_;
$i=0;
print ".";
}
} while ( !($out =~ /\nOK\r$/) && $i<50);
if( $i>=50){die("\nTimeout while retrieving list\n");}
# parse the list. First, split it on CRLF into lines.
@spis = split /\r\n/,$out;
print "\nFound pictures:\n";
foreach(@spis){
chomp;
# Comma-separated list. Only $id and $name is in use currently.
($id,$hidden,$len,$category,$content,
$location,$flag,$name)=split /,/i,$_,8;
# Dump all non-list lines.
next if !$name;
# Strip the "+KPSL: " invocation from first entry
(undef,$id)=split / /,$id;
# Strip quotes from filename
$name =~ s/^"(.*)"$/$1/g;
next if ( !$opt_B && ($blacklist =~ /\s$name\s/));
next if ( $opt_f && !($name =~ /${opt_f}/) );
$names{$name}=$id;
print "$name ";
}
end() if $opt_l;
# Grab all files...
if(!$opt_X) {
foreach(keys(%names)){
$name=$_;
print "\nretrieving $name...\n";
$i=0;
$out = snd('AT+KPSR='.$names{$name}); # Retrieve by ID.
# Rest of multi-line content
do {
$_ = $port->input;
if($_ eq ''){
select(undef,undef,undef,0.1);
print " ";
$i++;
} else {
$out .= $_;
$i=0;
print ".";
}
} while ( ! ($out =~ /\nNO CARRIER\r$/) && $i<50);
# 30s timeout total, giving up on this file,
# still chance the next one will be OK
if( $i>=50){print ("\nError retrieving $name\n"); next;}
print "\nExtracting...";
# Extract the second (and last) JPEG from the data retrieved.
# on my "myX6-2" phone the second header is missing
$out =~ m/$header.+?($endOfImage.+)\s+NO CARRIER/s;
$out = $1;
$out =~ s/$endOfImage/$header/i;
# $name = quotemeta($name);
print "writing...";
open(FILE,">$name.jpg");
print FILE $out;
close(FILE);
print "done.\n";
} # foreach name
} # if opt_X
# Delete files.
if($opt_X || $opt_x) {
foreach(keys(%names)){
$name = $_;
print "\nDeleting $name...\n";
$i=40; $out='';
$port->write("AT+KPSD=$names{$name}\r\n"); # Delete by ID.
do {
$out .= $port->input;
select(undef,undef,undef,0.5); # sleep 0.1s
print " .";
$i--;
if(($i>2) && ($out ne '')){$i=2;}
} while($i);
if($out =~ /OK/) { print "\nOK\n";} else {print "\nFailed\n";}
} # foreach name
} # if opt_Xx.
end();
# end of main
############################################################################
# subroutines.
# Send $snd, retry 10 times, for each retry wait 1s for answer.
sub snd
{
my($snd,$rec,$t,$j);
$snd=shift;
$t=10; # 10 resend retries
while($t){
$port->write("$snd\r\n");
$j=10;
$t--;
while ($j){
$j--;
$rec = $port->input;
if ( $rec ne '' ){
print ".";
return $rec;
}
select(undef,undef,undef,0.1); # sleep 0.1s
print " ";
} # Timeout
} # Retries
die("Timeout: No reply to $snd")
} # sub snd
sub VERSION_MESSAGE
{
if($opt_V){
print "
GETPIC
version 0.1b by Sharp '2004 (sharpy".'@'."xox.pl)
Picture downloader for Sagem Myx5-2
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Full license text: http://www.gnu.org/licenses/gpl.txt
";
} else {
print "getpic 0.1b";
}
end();
}
sub HELP_MESSAGE
{
print "
Usage:
getpic - use default settings, download all pictures
getpic -f regex - download all pictures matching regex
-p /dev/ttySn - use /dev/ttySn as port device (default ttyS0)
-b num - use num as baudrate (default 115200)
-l - list matching files only (then quit)
-B - skip blacklist matching (try copyrighted pics too)
-x - delete remote files after downloading
-X - delete remote files WITHOUT downloading
-h or --help - this help
-v or --version - version (brief)
-V - version and license
";
exit(0);
}
sub end
{
print "\n";
$port->close() if $port;
exit(0);
}
Kali.