--- linux2300.c.orig	2008-08-04 20:52:18.000000000 +0200
+++ linux2300.c	2008-08-04 20:56:14.000000000 +0200
@@ -15,6 +15,7 @@
 
 #include <errno.h>
 #include <sys/file.h>
+#include <libutil.h>
 #include "rw2300.h"
 
 /********************************************************************
@@ -30,19 +31,35 @@
 	WEATHERSTATION ws2300;
 	struct termios adtio;
 	int portstatus, fdflags;
+#ifdef __FreeBSD__
+	char *uucplock;
+#endif
 
 	//Setup serial port
 
+#ifdef __FreeBSD__
+	uucplock = strrchr(device, '/');
+	if (uucplock == NULL)
+		uucplock = device;
+	else
+		uucplock++;
+	if (uu_lock(uucplock) < 0) {
+		perror("\nSerial device is locked by other program\n");
+		exit(EXIT_FAILURE);
+	}
+#endif
 	if ((ws2300 = open(device, O_RDWR | O_NONBLOCK)) < 0)
 	{
 		printf("\nUnable to open serial device %s\n", device);
 		exit(EXIT_FAILURE);
 	}
 	
+#ifndef __FreeBSD__
 	if ( flock(ws2300, LOCK_EX|LOCK_NB) < 0 ) {
 		perror("\nSerial device is locked by other program\n");
 		exit(EXIT_FAILURE);
 	}
+#endif
 	
 	if ((fdflags = fcntl(ws2300, F_GETFL)) == -1 ||
 	     fcntl(ws2300, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
