# port linux script to bsd



## perhansen (Apr 30, 2009)

Hi all you wise guys.
I have bought this home solder kit http://quozl.netrek.org/ts/
It's a 4 channel temperature measurement.
Its plenty of linux and windows out there to get i running, so it shouldent be so hard.
I manage to get it running with my linux, but it seems a bit harder with freebsd.
I tried this binary code:


```
#!/usr/bin/perl

#system "stty 2400 cs8 > /dev/ttyd0 < /dev/ttyd0";

$sensor = $ARGV[0];

open DEV, "/dev/ttyd0" or die "Cannot open serial port!";

undef $outside;
undef $inside;

$reads = 0;

while (<DEV>) {
   chomp;
   next, unless (/[0-9] 00.*\./);
   ($id, $temp) = split(/ /);
   if ($sensor) {
      next, unless ($sensor == $id);
   }
   $id = $1, if ($id =~ /[^0-9]([0-9]+)/);
   $inside = $temp, if ($id == 1);
   $outside = $temp, if ($id == 2);
   if ($reads > 2 || (defined($outside) && defined ($inside))) {
      goto HERE;
   }
   $reads++;
}

HERE:
   $inneg = ($inside =~ /\-/);
   $outneg = ($outside =~ /\-/);
   $inside = $1, if ($inside =~ /0+(.*)/);
   $outside = $1, if ($outside =~ /0+(.*)/);
#   $inside = int($inside);
#   $outside = int($outside);
   $inside = "-" . $inside, if ($inneg);
   $outside = "-" . $outside, if ($outneg);
#   print "Inside:  $inside C\nOutside: $outside C\n";
   print "Inside:  $inside C Outside: $outside C\n";
```

I can actually see that this code is opening the port and receiving data, but nothing gets printed on the screen, not even a error message.
I don't know a thing about programming, so i can't find the problem my self.
I have tried several python codes, but nothing seems to work in bsd, maybe because the code is designed to run in linux.. :?
This program does the job quite well http://quozl.netrek.org/ts/tsl-1.2.tar.gz but its a sourcecode and needs to be compiled with the make command, witch doesn't exist in bsd. I then added the package gmake, but when i try compiling i get an error that cc is missing.

The only thing the code should do is save the temperatures in a log-file, witch i then print on my webpage with some php or even better if i could access the serial-port and read the temperature though php.

Please can anyone help me with this?


----------

