$dir = "C:/Users/hog/Desktop/DIYDrones/ardupilot-mega/libraries/GCS_MAVLink/include/common/"; $dir2 = "C:/Users/hog/Desktop/DIYDrones/ardupilot-mega/libraries/GCS_MAVLink/include/ardupilotmega/"; $fname = "MAVLinkTypes0.9.cs"; &doit(); # mavlink 1.0 with old structs $dir = "C:/Users/hog/Desktop/DIYDrones/ardupilot-mega/libraries/GCS_MAVLink/include_v1.0/common/"; $dir2 = "C:/Users/hog/Desktop/DIYDrones/ardupilot-mega/libraries/GCS_MAVLink/include_v1.0/ardupilotmega/"; $fname = "MAVLinkTypes.cs"; #&doit(); ; exit; sub doit { opendir(DIR,$dir) || die print $!; @files2 = readdir(DIR); closedir(DIR); opendir(DIR,$dir2) || die print $!; @files = readdir(DIR); closedir(DIR); push(@files,@files2); push(@files,"../mavlink_types.h"); open(OUT,">$fname"); $crcs = 0; %done = {}; print OUT <) { if ($line =~ /(MAVLINK_MESSAGE_LENGTHS|MAVLINK_MESSAGE_CRCS) (.*)/ && $crcs < 2) { print OUT "\t\tpublic byte[] $1 = new byte[] $2;\n"; $crcs++; } if ($line =~ /enum (MAV_.*)/) { $start = 1; print OUT "\t\tpublic "; } if ($line =~ /#define (MAVLINK_MSG_ID[^\s]+)\s+([0-9]+)/) { if ($line =~ /MAVLINK_MSG_ID_([0-9]+)_LEN/) { next; } else { print OUT "\t\tpublic const byte ".$1 . " = " . $2 . ";\n"; $no = $2; } } if ($line =~ /typedef struct(.*)/) { if ($1 =~ /__mavlink_system|param_union/) { last; } $start = 1; print OUT "\t\t[StructLayout(LayoutKind.Sequential,Pack=1)]\n"; #__mavlink_gps_raw_t $structs[$no] = $1; } if ($start) { $line =~ s/MAV_CMD_NAV_//; $line =~ s/MAV_CMD_//; $line =~ s/\/\/\/