Thread ByteArray in Perl abbilden (Code aus Python portieren) (4 answers)
Opened by prodigy7 at 2016-11-21 22:13

Gast prodigy7
 2016-11-22 21:36
#185635 #185635
Also so sieht es bei mir final aus:
Code: (dl )
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
        my($timezone) = (timegm(localtime(time)) - timelocal(localtime(time))) / -3600;
my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
$year += 1900;

my @data = ((0) x 39);

if($timezone < 0 ) {
$data[8] = 255 + $timezone - 1;
@data[9, 10, 11] = (255, 255, 255);
} else {
$data[8] = $timezone;
@data[9, 10, 11] = (0, 0, 0);
}

$data[12] = $year & 255;
$data[13] = $year >> 8;
$data[14] = $min;
$data[15] = $hour;
$data[16] = $year - 1900;
$data[17] = $wday;
$data[18] = $yday;
$data[19] = $mon;

$data[24] = int($ipSeg1);
$data[25] = int($ipSeg2);
$data[26] = int($ipSeg3);
$data[27] = int($ipSeg4);

$data[28] = $port & 255;
$data[29] = $port >> 8;

$data[38] = 6;

my($packet) = pack('C*', @data);
Die Zeile mit pack erzeugt dann die Meldung
Code: (dl )
Character in 'C' format wrapped in pack at broadlink.pl line ...
Was sagt mir die Meldung? Was läuft hier falsch?
Last edited: 2016-11-22 21:38:28 +0100 (CET)

View full thread ByteArray in Perl abbilden (Code aus Python portieren)