#!/usr/bin/perl -w


use strict;

my $ts1;
my $ts2;
my $sum;

my @sp = ( 0.8, 0.9 );
my $sp;

for ($ts1 = 15; $ts1 > 0; $ts1--) {
    my @min = (10); # (ts2, sum)
    my @max = (-1);
    for ($ts2 = 0; $ts2 < 8; $ts2++) {
	$sum = 1 + $ts1+1 + $ts2+1;
	$sp = (1+ $ts1+1) / $sum;

	if ($sp < $sp[0]) { last; }
	if ($sp > $sp[1]) { next; }

	if ($min[0] > $ts2) { @min = ($ts2, $sum, $sp); }
	if ($max[0] < $ts2) { @max = ($ts2, $sum, $sp); }
    }

    if (defined($min[2]) && defined($max[2])) {
	printf( "%3d   %d-%d  %2d-%2d  %.2f-%.2f\n", $ts1, $min[0], $max[0], $min[1], $max[1], $min[2], $max[2]);
    }
}

__END__

find possible can segment lengths with sample points between 80 and 90%

https://vector.com/portal/medien/cmc/application_notes/AN-AND-1-106_Basic_CAN_Bit_Timing.pdf
