Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

Options
24

Comments

  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices

    Still didn't work, same error. Here's what's installed library wise from the Ubuntu Software Center. This is all that's listed for modbus. The green check marks are installed.

    Attachment not found.

    Glen

    Edit: Tom, there might be something in this link that will shed some light as to the compile issue?. It's all beyond my knowledge at this point.

    http://manpages.ubuntu.com/manpages/precise/man7/libmodbus.7.html

    or this one. https://forum.openwrt.org/viewtopic.php?id=38605 I tried changing the #include to #include <modbus/modbus.h>, still didn't work, but got different error in the terminal.

    glen@glen-Aspire-1810T:~/Desktop$ cc `pkg-config --cflags --libs libmodbus` suresinetest.c -o suresinetest
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/../lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: cannot find -lmodbus
    collect2: error: ld returned 1 exit status
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices
    Muskoka wrote: »
    Still didn't work, same error. Here's what's installed library wise from the Ubuntu Software Center. This is all that's listed for modbus. The green check marks are installed.

    Did it still have the modbus.h error or did that go away when you installed libmodbus-dev?
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices
    Muskoka wrote: »
    Edit: Tom, there might be something in this link that will shed some light as to the compile issue?. It's all beyond my knowledge at this point.

    http://manpages.ubuntu.com/manpages/precise/man7/libmodbus.7.html

    Also double check that pkg-config is installed.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices

    I just looked in Nautilis and I do have modbus.h inside "usr/include/modbus". Yes, pkg-config is installed. The modus.h error went away when I changed from "#include <modbus.h>" to "#include <modbus/modbus.h>". I just tried changing it to usr/include/modbus/modbus.h, got the modbus.h not found error again.

    Glen

    Edit: looks like something is wrong in "usr/bin/ld", it's always referenced in the errors in the terminal.
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices
    Muskoka wrote: »
    Edit: looks like something is wrong in "usr/bin/ld", it's always referenced in the errors in the terminal.

    ld is the linker program the compiler uses to build the software. I doubt there is anything wrong with it. I think the problem is with the Ubuntu verson of the libmodbus package. It looks like it is installing a slightly older version of the libmodbus library (3.0.1). If your machine is an i386 (Intel or compatible processor - it looks like it is), have you tried installing the i386 packages that didn't have the green checks?
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/../lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../libmodbus.so when searching for -lmodbus
    /usr/bin/ld: skipping incompatible /usr/lib/libmodbus.so when searching for -lmodbus
    /usr/bin/ld: cannot find -lmodbus
    collect2: error: ld returned 1 exit status

    From this, I'd say pkg-config and ld are finding the library, but it is not compatible with your system. The problem may also be the the package is not built for the x86_64 distribution, but if so, I don't understand why the package manager would allow it to be installed. I don't know what else to suggest.

    As an alternative, you could uninstall all the libmodbus packages using the package manager and install it manually following my directions on http://westyd1982.wordpress.com/ - bottom post. This is not as nice as having it in a prebuilt package that will get normal updates, but it should work.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for Morningstar Devices

    I did go back and install the i386 packages, no difference. I'll look at doing the manual install.

    Glen
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Hey, I have a compiled "suresinetest". I removed all the packages that I installed earlier from software sources, and did the manual install as per your instructions and it worked. Now the fun part. I think I need to edit suresinetest.c first and change the address, correct, then re-complie?

    Glen

    Edit: Just tried and get nothing. I have the phone cable in the SureSine, it's connected to the MSC, my Serial to USB is connected to the MSC and my laptop. In the terminal I run "suresinetest" and it says:

    suresinetest: command not found

    Will investigate more.
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT
    Muskoka wrote: »
    Hey, I have a compiled "suresinetest". I removed all the packages that I installed earlier from software sources, and did the manual install as per your instructions and it worked. Now the fun part. I think I need to edit suresinetest.c first and change the address, correct, then re-complie?

    Glen

    Edit: Just tried and get nothing. I have the phone cable in the SureSine, it's connected to the MSC, my Serial to USB is connected to the MSC and my laptop. In the terminal I run "suresinetest" and it says:

    suresinetest: command not found

    Will investigate more.

    Try ./suresinetest in the same directory as suresinetest. Also you do want to edit suresinetest.c to match your setup - serial port and MODBUS address. The wiring to the SureSine sounds correct (The phone cable needs to have at least 4 conductors attached at each end - the MSC came with a 6 conductor phone cable). Have you tried it with MSView? It should work also.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    I got my Tristar PWM to work.

    In Ubuntu I had to do this first though:

    This was the error...

    "ERROR Can't open the device /dev/ttyUSB0 (Permission denied)"

    So I typed this in the terminal...

    glen@glen-Aspire-1810T:~$ sudo adduser glen dialout
    Adding user `glen' to group `dialout' ...
    Adding user glen to group dialout
    Done.

    Then this....

    glen@glen-Aspire-1810T:~$ sudo chmod a+rw /dev/ttyUSB0

    Then when I run ./tristarpwmtest from the terminal I get this....

    glen@glen-Aspire-1810T:~$ ./tristarpwmtest
    adc_vb_f=13.02
    adc_vs_f=12.92
    adc_vx_f=12.97
    adc_ipv_f=4.31
    adc_iload_f=0.00



    I'll go back and try the SureSine, kinda know what I'm doing now.

    Glen

    Tom, I just tried with the SureSine and I get "Connection timed out" in the terminal.
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Excellent! It is good to know tristarpwmtest works. That is exactly what the output should look like.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    It connects to my MPPT but I don't get any values/readings?

    glen@glen-Aspire-1810T:~$ ./tristarmppttest
    V_PU_hi=0
    V_PU_lo=0
    I_PU_hi=0
    I_PU_lo=0
    ver_sw=0x0
    V_PU=0.00000
    I_PU=0.00000

    Every time I try it I have to enter this command first.

    glen@glen-Aspire-1810T:~$ sudo chmod a+rw /dev/ttyUSB0

    or I get this....

    glen@glen-Aspire-1810T:~$ ./tristarmppttest
    ERROR Can't open the device /dev/ttyUSB0 (Permission denied)

    I must have to edit some file or something, this would get annoying after a while. I still can't connect to the SureSine, get this error...

    glen@glen-Aspire-1810T:~$ ./suresinetest
    Connection timed out

    Glen
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    I fixed a set of silly mistakes in tristarmppttest.c. It should work now.

    I also updated suresinetest.c with the MODBUS address set to 0x01.

    I'm not sure why your serial port settings "sudo chmod a+rw /dev/ttyUSB0" and "sudo adduser glen dialout" don't seem to be sticking. As an alternative, you can just run the program as a super user:

    sudo ./tristarmppttest

    On suresinetest, I'm not sure why you are getting the time out error. On your SureSine, is switch 4 in the UP (MODBUS) position and can you connect to it with MSView?

    - Tom
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Messed my Linux box up, decided to install Lubuntu, now I'm back at square one, can't compile any of the examples. My Hello World program complies fine, so I know that's working. Same problem as before....

    glen@glen-Aspire-1810T:~/Downloads/basicexamples$ cc `pkg-config --cflags --libs libmodbus` suresinetest.c -o suresinetest
    /tmp/ccek3E6C.o: In function `main':
    suresinetest.c:(.text+0x23): undefined reference to `modbus_new_rtu'
    suresinetest.c:(.text+0x67): undefined reference to `modbus_set_slave'
    suresinetest.c:(.text+0x73): undefined reference to `modbus_connect'
    suresinetest.c:(.text+0x86): undefined reference to `modbus_strerror'
    suresinetest.c:(.text+0xae): undefined reference to `modbus_free'
    suresinetest.c:(.text+0xd5): undefined reference to `modbus_read_registers'
    suresinetest.c:(.text+0xec): undefined reference to `modbus_strerror'
    suresinetest.c:(.text+0x281): undefined reference to `modbus_close'
    suresinetest.c:(.text+0x28d): undefined reference to `modbus_free'
    collect2: error: ld returned 1 exit status
    glen@glen-Aspire-1810T:~/Downloads/basicexamples$

    Sometimes Linux can be a real pain in the butt. Does it have anything to do with where I'm trying to compile from, the directory I'm using?

    Anyway, got the suresine to talk to another laptop I have in MSView, it helps if you use a cable with at least four wires. Both the other cables I had were only two wire..

    Glen
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Got it to work with the suresine.

    Had to change this:

    #include <modbus.h>

    to this:

    #include <modbus/modbus.h>

    Then I could compile.

    I also have to do this once:

    glen@glen-Aspire-1810T:~/Downloads/basicexamples$ sudo adduser glen dialout
    Adding user `glen' to group `dialout' ...
    Adding user glen to group dialout
    Done.

    And then this every time I want to connect:

    glen@glen-Aspire-1810T:~/Downloads/basicexamples$ sudo chmod a+rw /dev/ttyUSB0


    Glen
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Ok, got the "permissions" issue sorted out. This is for the Linux newbies, like me. I followed this example. All my .rules files in /etc/udev/rules.d/ started with "70", so I changed the 40- to 70-. Because we're using USB devices you also need to change the ttys[0-9], to ttyUSB[0-9]. After doing these steps the permissions error has never returned, and you will have access to the device as soon as it's plugged in. I don't know if this can cause security issues, I'll let the Linux experts speak about that. All I know is it fixed the permission issues when I was plugging in my "serial to usb" cable for connection to the suresine through the msc.

    I'm using Lubuntu 12.10......

    "In order to get read/write permission on /dev/ttyS0 add your user to the dialout group.

    Code:

    sudo addgroup $USERNAME dialout


    You can set the permissions of /dev/ttyS0 by editing the /etc/udev/rules.d/40-permissions.rules file:

    Code:

    sudo gedit /etc/udev/rules.d/40-permissions.rules

    Add this line:
    KERNEL=="ttyS[0-9]", GROUP="dialout", MODE="0777"

    restart udev:

    Code:

    sudo /etc/init.d/udev restart"


    Glen
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT
    Muskoka wrote: »
    Got it to work with the suresine.

    Now that you got it to work with your SureSine, you should be able to run the complete example that displays all the RAM and EEPROM registers. You will need to make the same edits you did for suresinetest.c.

    - Tom
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Actually, just about ready to pack it in. It's non stop errors, one minute it works, then it doesn't. I keep getting the "undefined reference" errors....

    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc `pkg-config --cflags --libs libmodbus` suresine.c -o suresine
    /tmp/ccZI7DZD.o: In function `main':
    suresine.c:(.text+0x35): undefined reference to `modbus_new_rtu'
    suresine.c:(.text+0x79): undefined reference to `modbus_set_slave'
    suresine.c:(.text+0x85): undefined reference to `modbus_connect'
    suresine.c:(.text+0x98): undefined reference to `modbus_strerror'
    suresine.c:(.text+0xc0): undefined reference to `modbus_free'
    suresine.c:(.text+0xe7): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0x778): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xaa5): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xb3c): undefined reference to `modbus_close'
    suresine.c:(.text+0xb48): undefined reference to `modbus_free'
    collect2: error: ld returned 1 exit status


    Glen
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT
    Muskoka wrote: »
    Actually, just about ready to pack it in. It's non stop errors, one minute it works, then it doesn't. I keep getting the "undefined reference" errors....

    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc `pkg-config --cflags --libs libmodbus` suresine.c -o suresine
    /tmp/ccZI7DZD.o: In function `main':
    suresine.c:(.text+0x35): undefined reference to `modbus_new_rtu'
    suresine.c:(.text+0x79): undefined reference to `modbus_set_slave'
    suresine.c:(.text+0x85): undefined reference to `modbus_connect'
    suresine.c:(.text+0x98): undefined reference to `modbus_strerror'
    suresine.c:(.text+0xc0): undefined reference to `modbus_free'
    suresine.c:(.text+0xe7): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0x778): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xaa5): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xb3c): undefined reference to `modbus_close'
    suresine.c:(.text+0xb48): undefined reference to `modbus_free'
    collect2: error: ld returned 1 exit status


    Glen

    It is just not seeing the header file modbus.h. Did you change:

    #include <modbus.h>

    to:

    #include <modbus/modbus.h>
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Hi Tom...

    I just tried with "#include <modbus.h>" and "#include<modbus/modbus.h>" and both times I get the same error.

    glen@glen-Aspire-1810T:~$ cd Downloads/suresine
    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc `pkg-config --cflags --libs libmodbus` suresine.c -o suresine
    /tmp/cc4ueEoO.o: In function `main':
    suresine.c:(.text+0x35): undefined reference to `modbus_new_rtu'
    suresine.c:(.text+0x79): undefined reference to `modbus_set_slave'
    suresine.c:(.text+0x85): undefined reference to `modbus_connect'
    suresine.c:(.text+0x98): undefined reference to `modbus_strerror'
    suresine.c:(.text+0xc0): undefined reference to `modbus_free'
    suresine.c:(.text+0xe7): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0x778): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xaa5): undefined reference to `modbus_read_registers'
    suresine.c:(.text+0xb3c): undefined reference to `modbus_close'
    suresine.c:(.text+0xb48): undefined reference to `modbus_free'
    collect2: error: ld returned 1 exit status


    If I use this method:

    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc -c suresine.c

    It complies. Then I try this:

    glen@glen-Aspire-1810T:~/Downloads/suresine$ sudo cc -o suresine suresine.c

    and I get this:

    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc -o suresine suresine.c
    suresine.c:27:20: fatal error: modbus.h: No such file or directory
    compilation terminated.
    glen@glen-Aspire-1810T:~/Downloads/suresine$

    So, either way I can't get it to work now.


    Glen

    edit: The system is putting those smileys in, don't know why.

    edit2: If I try this

    glen@glen-Aspire-1810T:~/Downloads/suresine$ cc -c suresine.c

    without <modbus/modbus.h> it won't complie.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Question Tom...

    The modbus.h file and the other 3 modbus files are in /usr/local/include/modbus. I notice there is also a /usr/include. There's no modbus stuff in there, is that a issue?

    Glen
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    OMG, I have been at this all day...and finally got it.

    Here's the issue. I don't know enough about Linux to know if this is just an Lubuntu/Ubuntu thing or not, but it worked. Tom, I was able to leave the statement "#include <modbus.h>" as is.

    this:

    cc `pkg-config --cflags --libs libmodbus` suresine.c -o suresine

    needs to be this:

    cc suresine.c `pkg-config --cflags --libs libmodbus` -o suresine

    Now they all compile just fine, here is the output from the SureSine...

    glen@glen-Aspire-1810T:~/Downloads/basicexamples$ ./suresine
    RAM Registers

    adc_vb = 12.52 V
    adc_iac = 0.2871 A
    adc_ths = 10.18 V
    adc_remon = 0.00 V
    Vb = 12.47 V
    Iac = 0.5685 A
    Ths = 25 °C
    fault = SureSine Faults = 0
    No faults
    alarm = SureSine Alarms = 0
    No alarms
    dip_switch = DIP switch settings
    Switch 1 OFF - Power Mode = Always On
    Switch 2 OFF - LVD = 11.5 V, LVR = 12.6 V
    Switch 3 OFF - Beeper Warning On
    Switch 4 ON - MODBUS Protocol
    load_state = 1 Load On
    mod_index = 39.45 %
    volts = 115 V
    hertz = 60 Hz
    m_disconnect = 0
    modbus_reset = 0

    EEPROM Registers

    EVb_min = 12.52 V
    EVb_max = 0.14 V
    Emodbus_id = 39424
    Emeter_id = 0
    EV_lvd2 = 12.47 V
    EV_lvr2 = 0.28 V
    EV_hvd2 = 0.01 V
    EV_hvr2 = 0.00 V
    Et_lvd_warn2 = 0.0 s
    EV_lvdwarn_beep2 = 0.00 V
    EV_lvrwarn_beep2 = 0.00 V
    EV_startlvd2 = 0.00 V
    Ehourmeter = 6824
    Eserial_no = 10290473

    Here is the post I found on-line where the guy was having an issue compiling in Ubuntu. He was seeing the same "undefined reference" errors. I tried what he was told to do, and it worked. Move the source file to the front.

    "You should compile with source file appearing before the libraries as gcc hello.c $(pkg-config --cflags --libs gtk+-3.0) -o hello, the reason being the behavior of linker i.e it does not link the libraries unless the symbols of that library is seen prior in compilation.
    Hope this helps!"

    Glen

    Edit: Tom, in the "full" suresine code there was a typo on the second line listed below, tty.solar, should be ttyUSB0. The program let me know when I tried to connect.

    /* Set up a new MODBUS context */
    ctx = modbus_new_rtu("/dev/tty.solar", 9600, 'N', 8, 2);
    if (ctx == NULL) {
    fprintf(stderr, "Unable to create the libmodbus context\n");
    return -1;
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    How odd that the order would matter. On my system it doesn't. All of these work:

    cc `pkg-config --cflags --libs libmodbus` suresine.c -o suresine
    cc suresine.c `pkg-config --cflags --libs libmodbus` -o suresine
    cc suresine.c -o suresine `pkg-config --cflags --libs libmodbus`
    cc -o suresine suresine.c `pkg-config --cflags --libs libmodbus`

    My output numbers are also a little different (particularly the EEPROM values):

    RAM Registers

    adc_vb = 12.48 V
    adc_iac = 0.1095 A
    adc_ths = 10.41 V
    adc_remon = 0.02 V
    Vb = 12.51 V
    Iac = 0.1368 A
    Ths = 23 °C
    fault = SureSine Faults = 0
    No faults
    alarm = SureSine Alarms = 0
    No alarms
    dip_switch = DIP switch settings
    Switch 1 OFF - Power Mode = Always On
    Switch 2 OFF - LVD = 11.5 V, LVR = 12.6 V
    Switch 3 OFF - Beeper Warning On
    Switch 4 ON - MODBUS Protocol
    load_state = 1 Load On
    mod_index = 38.28 %
    volts = 115 V
    hertz = 60 Hz
    m_disconnect = 0
    modbus_reset = 0

    EEPROM Registers

    EVb_min = 0.85 V
    EVb_max = 15.10 V
    Emodbus_id = 2
    Emeter_id = 1
    EV_lvd2 = 10.50 V
    EV_lvr2 = 11.60 V
    EV_hvd2 = 15.50 V
    EV_hvr2 = 14.50 V
    Et_lvd_warn2 = 240.0 s
    EV_lvdwarn_beep2 = 10.80 V
    EV_lvrwarn_beep2 = 11.80 V
    EV_startlvd2 = 10.20 V
    Ehourmeter = 25840
    Eserial_no = 09330132

    In suresine.c, you might try adding:

    sleep(1);

    before each place it reads the EEPROM registers just to give the suresine time to get out each response.
  • inetdog
    inetdog Solar Expert Posts: 3,123 ✭✭✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT
    Muskoka wrote: »
    OMG, I have been at this all day...and finally got it.

    Here's the issue. I don't know enough about Linux to know if this is just an Lubuntu/Ubuntu thing or not, but it worked.

    It is not so much a specific Ubuntu thing as it is a cc thing. In any system the favorite C compiler is usually aliased (symlinked) as cc. The Gnu C compiler will be gcc.
    Some C compilers will look ahead through all of the source file and libraries before going to the step of linking the various routines. Others will process the source files in order to the maximum extent possible.
    From a tutorial on compiling for the FreeBSD platform:
    -llibrary
    Specify a function library to be used at link time.

    The most common example of this is when compiling a program that uses some of the mathematical functions in C. Unlike most other platforms, these are in a separate library from the standard C one and you have to tell the compiler to add it.

    The rule is that if the library is called libsomething.a, you give cc the argument -lsomething. For example, the math library is libm.a, so you give cc the argument -lm. A common “gotcha” with the math library is that it has to be the last library on the command line.

    % cc -o foobar foobar.c -lm
    In your case the -l operand is --libs instead.
    SMA SB 3000, old BP panels.
  • Muskoka
    Muskoka Solar Expert Posts: 103 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Thanks for the info. As you can probably tell, I'm not at a programmer. I have looked at Python more than a few times, but could get never get my head around it, or what I could / would do with it. This has me inspired to look at it again, if anything, just to see if I can read something from one of my units.

    Tom, I'll try the "sleep" command(?) and report back. Easter weekend so I'm off this morning for about five days, won't be able to do any more "playing" at my end. I used to have another laptop set-up with Teamviewer on it so I could access my system remotely, I sold that laptop and the only other spare I have is a pig on power. The one I'm on now is going with me, so I'm out of luck. I need to come up with a better remote solution hardware wise. I would like to be able to access "all" my Morningstar stuff, and my Midnite Classic when it shows up. My only internet access is a Turbo Hub (cellular), with dynamic ip's. Teamviewer works fine, but it would be nice to not have to use that layer to get access. Static ip's are not available to the public with my provider, only business accounts. Any suggestions, I know a bit about networking, but haven't figured out how I can access my local network, remotely.

    Have a good weekend guys......Glen
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    To get around the dynamic IP address issue, you should be able to use something like DynDNS or one of the many other dynamic DNS solutions (see http://en.wikipedia.org/wiki/Dynamic_DNS).
  • jwrgorman
    jwrgorman Registered Users Posts: 22 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT and SureSine-300

    Thanks for that, we support Morningstar TS45 and TS60 and the TS45 MPPT controller in our Java based framework called SolarNetwork on Sourceforge and Github. We also support Outback, SMA, Xantrex, Enasolar and some Modbus devices over 485. If anyone is interested in implementing the interface for other devices, please let me know! Thanks, John

    http://sourceforge.net/projects/solarnetwork/

    https://github.com/SolarNetwork

    http://www.solarnetwork.net/developmentGuides.php
    John Gorman / SolarNetwork Foundation
    e:john@solarnetwork.net
  • crakalakin
    crakalakin Registered Users Posts: 1
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT and SureSine-300
    westyd1982 wrote: »
    If anyone is using this open source software, this past weekend, I updated the example and all the code for the SunSaver MPPT and SureSine-300 to work with the latest version of libmodbus (3.0.2). It looks like libmodbus will be a supported package that can be easily installed in the Debian-based Linux distributions in the upcoming version later this year.

    I just had to sign up for this forum to let you know how big of a help your original code was. I found it on your blog last year when I swapped out my Morningstar Prostar for a Sunsaver MPPT. I just have a small setup I've been experimenting throughout college with and I wanted to grab the data from it. I've built off of your original code quite extensively lately and have it all on my github account, linked below. I run it on a Raspberry Pi (setup instructions for Arch linux are in the link below). Today I swapped out my USB->RS232 adapter with a MAX3232 chip and will be writing about that soon, hopefully will be able to eventually make a box for the Raspberry Pi with the DB9 connector builtin to clean up the wires. I have mine reading every 5 seconds and dumping into Redis, an in memory key/value database. I then have a Ruby server setup (code also below) that the Raspberry Pi can send the readings to in JSON format and save it to a PostgresSQL database for further analysis. The web front end is not built yet, but I have plans to graph and analyze everything in realtime at some point, possibly with an iOS app.

    Again, thanks for that original code. It was a huge help.


    Code on Github Here
    MAX3232 breakout from SparkFun
    Ruby/Postgres server to dump data to
  • okiejim
    okiejim Registered Users Posts: 16 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    Just found this thread. Thank you for posting this information. I can't wait to try. I'm not a programmer either but this thread will help me be able to get it going. I had msview for my tristar-ts45 running on windows 8 until I got a virus and had to wipe my drive and lost windows. So now running Fedora 19. I like it alot better than windows but wanted to see my tristar. I hope to download the software tomorrow at work and try. Thank you again. I will let you know what happens later in the week after I have a change to make the approriate changes. I sure do appriciate your work and look forward to monitoring my solar panels again.
  • westyd1982
    westyd1982 Solar Expert Posts: 85 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT and SureSine-300
    crakalakin wrote: »
    I just had to sign up for this forum to let you know how big of a help your original code was. I found it on your blog last year when I swapped out my Morningstar Prostar for a Sunsaver MPPT. I just have a small setup I've been experimenting throughout college with and I wanted to grab the data from it. I've built off of your original code quite extensively lately and have it all on my github account, linked below. I run it on a Raspberry Pi (setup instructions for Arch linux are in the link below). Today I swapped out my USB->RS232 adapter with a MAX3232 chip and will be writing about that soon, hopefully will be able to eventually make a box for the Raspberry Pi with the DB9 connector builtin to clean up the wires. I have mine reading every 5 seconds and dumping into Redis, an in memory key/value database. I then have a Ruby server setup (code also below) that the Raspberry Pi can send the readings to in JSON format and save it to a PostgresSQL database for further analysis. The web front end is not built yet, but I have plans to graph and analyze everything in realtime at some point, possibly with an iOS app.

    Again, thanks for that original code. It was a huge help.

    It sounds like a neat project!
  • notsobright
    notsobright Solar Expert Posts: 247 ✭✭
    Options
    Re: Linux (and Mac OS X) MODBUS Software for SunSaver MPPT

    hi westyd1982, I still havnt had a chance to try this out yet but I had some old routers out recently and thought about it again.

    is it possible that you could run this directly on a router and have the webpage results transmitted so that you could monitor anytime you are in range of the router? Im considering what solutions are available to monitor SSI & SSD in RV remotely again.

    Ive still got some old WRT54GS with serious hardware mods (64mb RAM & micro SD card storage) and it seems possible.. run from SD or possibly mod the firmware.

    what ya think?

    a quick glance at the MODBUS specs between the SSD and MTTP controllers seems to be quite different though and modifing your basicexample to work also seems possible but not something I have any experience with however if I can determine that it would be possible I might just go for it.

    a healthy learning experience and possibly a great monitor kit!