sub frame2packet { my @frame = @_; my $packet = ''; foreach my $byte (@frame) { my $lowbyte = ($byte & 0x0f) + 65; my $highbyte = ($byte >> 4) + 65; $packet .= chr($highbyte); $packet .= chr($lowbyte); } return $packet; } sub packet2frame { my $packet = shift; my @chars = split//, $packet; my @frame = (); # Decode to bytes while(@chars) { my $high = shift @chars; my $low = shift @chars; my $val = ((ord($high) - 65) << 4) + (ord($low) - 65); push @frame, $val; } return @frame; } #### highbyte = 0x02; Serial.write(highbyte); for(inoffs = 0; inoffs < PKT_LEN; inoffs++) { intmpbyte = inpacket[inoffs]; highbyte = ((intmpbyte >> 4) & 0x0f) + 65; lowbyte = (intmpbyte & 0x0f) + 65; Serial.write(highbyte); Serial.write(lowbyte); } highbyte = 0x03; Serial.write(highbyte);