Use FreeNAS and X10

Status
Not open for further replies.

Mar10us

Cadet
Joined
Oct 21, 2013
Messages
4
Hello Guys,

I'd like to use a X10 controller (CM15Pro) in a FreeNAS 9.1.1 Jail.
I've searched the internet, and found out that mochad is a working solution to get the controller working in a linux/unix machine. To compile it, you need libusb-1.0-dev which I cannot find for FreeNAS/FreeBSD. Can someone please lead me the way to compile it? I'm a bit of a nix-noob :(.

Thank you very much!

Martijn
 
D

dlavigne

Guest
mochad hasn't been ported to FreeBSD yet. I also suspect that hardware drivers will be needed which I doubt are included in FreeNAS.
 

Mar10us

Cadet
Joined
Oct 21, 2013
Messages
4
Thank you for your answer dlavigne!
With some help of a linux-guru I managed to get it working.
I had to include some library and changed some code. The end result is that it works for me!

Details, before compiling:

  • setenv CPPFLAGS "-I/usr/local/include"
  • setenv LDFLAGS "-lusb"
  • ./configure
  • make
Greetz...
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,525
Did you actually try that and it worked? If so it would be appreciated if you could post your steps for others. Clearly those 4 steps aren't enough on their own.

I'm asking because as soon as you said "linux-guru" I thought "FreeBSD isn't linux". For most questions on the forum that have comments like "linux-guru" the end result is that their advice was about as useful as asking a Windows or Mac admin....
 

Mar10us

Cadet
Joined
Oct 21, 2013
Messages
4
Cyberjock,

I actually tried it, and it worked!

The reason I called my friend a linux-guru, is that he knows so much more of linux than I do.
Probably that says so much more of me than of him..... ;)
I know FreeNAS is based on (Free)BSD, but the system is more like linux than Windows isn't it?

Anyway: the steps I used to complete my task:

1. mkdir /usr/local/mochad
2. cd /usr/local/mochad
3. wget http://downloads.sourceforge.net/project/mochad/mochad-0.1.16.tar.gz
4. tar zxvf mochad-0.1.16.tar.gz
5. cd mochad-0.1.16.tar.gz
6. setenv CPPFLAGS "-I/usr/local/include"
7. setenv LDFLAGS "-lusb"

When you try to compile the file at this point, you will get an error:

decode.o: In function `get_timems':
/usr/local/mochad/mochad-0.1.16/decode.c:591: undefined reference to `ftime'
*** [mochad] Error code 1

You have to make a small change to the file: /usr/local/mochad/decode.c
But first, make a copy, just to be sure...

8. cp /usr/local/mochad/mochad-0.1.16/decode.c /usr/local/mochad/mochad-0.1.16/decode.c.orig


Edit the file decode.c in your favorite editor.

Comment out the include <sys/timeb.h> section:
/*#include <sys/timeb.h>*/

Insert the following include:
#include <sys/time.h>

Find the comment /* Get system time in milliseconds */

Change the section below form:
/* Get system time in milliseconds */
static timems_t get_timems(void)
{
struct timeb tp;

ftime(&tp);
return (timems_t) (tp.time * 1000) + tp.millitm;
}

To:
/* Get system time in milliseconds */
static timems_t get_timems(void)
{
struct timeval tp;
struct timezone tz;

gettimeofday(&tp, &tz);
return (timems_t) (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
}
Save your file.
Now compile!
9. make clean
10. make
11. start mochad, and have fun!
I hope this instruction was detailed enough and will be of some use to anybody.
Martijn
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,525
I know FreeNAS is based on (Free)BSD, but the system is more like linux than Windows isn't it?

Not really. That's like saying Windows is like MacOS. It's not really. And comparing Linux to FreeBSD can often start a nerd jihad because many people from each side hate the other.
 

Arjan

Cadet
Joined
Dec 12, 2013
Messages
6
Martijn,

Perhaps i may pop a question after two months ?

I don't get your procedure completely clear:

* On which platform did you run the compile ? When i try it on the freenas 9.2 platform, the first issue that pops up is that the /usr/local is a read only location, and that it is not allowed to create a file.

* In a jail, the system doesn't know the command make clean.

Can you please provide me with some more information ? Perhaps i missed something ?

Regards,

Arjan
 

Arjan

Cadet
Joined
Dec 12, 2013
Messages
6
And of course. In case of a jail, which type of jail i have te use.

Regards,

Arjan
 

Mar10us

Cadet
Joined
Oct 21, 2013
Messages
4
And of course. In case of a jail, which type of jail i have te use.

Regards,

Arjan


I'm using a standard jail.
Be sure to fetch and extract all the ports inside the jail.
That is:
  • portsnap fetch
  • portsnap extract
the make command lives at /usr/bin

Martijn
 
D

dlavigne

Guest
* In a jail, the system doesn't know the command make clean.

Whenever you run across an error like this, make sure you are in the correct directory. Typically, this error means that there is no Makefile in the current directory, meaning you are not in the subdirectory for the port (or src) that you wish to compile.
 

Arjan

Cadet
Joined
Dec 12, 2013
Messages
6
Thanks all for your imput.

for now i still didn't have the time to try these steps. Hope to find some time the next week.

regards,


Arjan
 
Status
Not open for further replies.
Top