Linux query

Discussion in 'C-Gate Developers' started by Mr Mark, Aug 8, 2012.

  1. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    Hello all.
    I've got another one for you...
    Any linux guys out there? I'm running C-Gate on a linux box and so far so good - Ports 20023 (command) and 20025 (feedback) are working as expected, but using Toolkit on a client PC to connect to remote c-gate on 20123 immediately returns a "Cannot connect to C-Gate Server". This is my first go with Linux, so I'm probably missing something simple?
    Using c-gate on another PC (Windows) as a server isn't new to me either, so I'm thinking it's something on the linux box I need to overcome.
    BTW, Linux is Debian running on a 'Raspberry Pi'.

    Thanks,

    Mark
     
    Mr Mark, Aug 8, 2012
    #1
    1. Advertisements

  2. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    Hiya, I just tested with C-Gate 2.9.0 build 2449 on a Ubuntu 12.04 box.

    I did a few things first.

    1. Dropped the attached file into the C-Gate2 directory ( libjspLux86_64bit.so - remember to extract it!)

    It is the linux serial library. I hope to include it in a release soon.

    2. Created a cgate.sh in the C-Gate2 directory with the following 2 lines and made it executable:

    DEVICE_LIST=`ls -1 /dev/tty* | grep USB | paste -sd ":"`
    java -Djava.library.path=. -DSERIAL_PORT_LIST=$DEVICE_LIST -jar cgate.jar

    This little launcher sorts out the path issue for the library and makes the serial ports useable.

    3. Added one entry to C-Gate2\config\access.txt:

    interface 205.96.255.255 Program

    The 255's act as wildcards, so you can define exactly the network subnet you want to grant remote access to C-Gate.

    Having set that up, I can successfully connect to the remote C-Gate from Toolkit on a Windows machine and scan a PCI-based network.

    If the above doesn't help you, you can turn on level 9 logging (either following the instructions here or the quick and dirty approach of typing "events e9s0c0" in the command window on port 20023).

    When Toolkit connects you should see lines such as:

    20120813-154522 803 cmd11 - Host:server.domain.com/205.96.136.238 opened command interface from port: 3594
    20120813-154522 899 sys Debug: New Command Context: cc041 = AccessContext Session server.domain.com/205.96.136.238#12
    20120813-154522 766 cmd11 - Response: 201 Service ready: Clipsal C-Gate Version: v2.9.0 (build 2449) #cmd-syntax=1.0
    20120813-154522 761 cmd11 - Command: &4[453]get cgate version
    20120813-154522 766 cmd11 - Response: [453] 300 cgate: version=v2.9.0 (build 2449)

    If however you see lines such as the following:

    20120813-143828 804 cmd5 - Host:server.domain.com/205.96.136.238 closed command interface from port: 3527
    20120813-143831 766 cmd7 - Response: 421 Connection refused.
    20120813-143831 805 cmd7 - Access control refused connection from server.domain.com/205.96.136.238

    Then there is something still not right with the access.txt.

    If you don't see these lines at all, then something is blocking the connection even before it gets to C-Gate.

    Hope that helps!
     

    Attached Files:

    Last edited by a moderator: Aug 13, 2012
    daniel, Aug 13, 2012
    #2
    1. Advertisements

  3. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    remote c-gate

    Hello Daniel.

    There doesn't appear to be any problems on the access side (I can use ports 20023 and 20025 OK). For clarification, I had added the line "Remote 255.255.255.255 Program" to the access.txt file. Also added "interface 255.255.255.255 Program".
    As I'm using a CNI, I shouldn't need your patch.
    When I try to connect with Toolkit I get the following:

    #e# 20120813-153900 803 cmd13 - Host:/10.0.0.12 opened command interface from port: 51187
    #e# 20120813-153900 899 sys Debug: New Command Context: cc069 = AccessContext Session / 10.0.0.12#14
    #e# 20120813-153900 766 cmd13 - Response: 210 Service ready: Clipsal C-Gate on Raspberry Pi Version: v2.9.0 (build 2449)
    #cmd-syntax=1.0
    #e# 20120813-153900 804 cmd13 - Host:/10.0.0.12 closed command interface from port: 51187

    So... it's showing my laptop (10.0.0.12) is trying to connect and yes, I did modify the c-gate server name so I know which one I'm connecting to. No other change to the C-GateConfig.txt file.
     
    Last edited by a moderator: Aug 13, 2012
    Mr Mark, Aug 13, 2012
    #3
  4. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    I changed my server name to match yours (in case TK expects a hardcoded value), but that seems to work fine.

    I also tried connecting from an older Toolkit (v1.11.12) and noted that it executes 2 commands (and produces a fairly obvious API error) before it closes the connection due to incompatibility:

    20120813-161005 766 cmd7 - Response: 201 Service ready: Clipsal C-Gate on Raspberry Pi Version: v2.9.0 (build 2449) #cmd-syntax=1.0
    20120813-161005 761 cmd7 - Command: &4[4]get cgate version
    20120813-161005 766 cmd7 - Response: [4] 300 cgate: version=v2.9.0 (build 2449)
    20120813-161006 761 cmd7 - Command: &4[5]apiver
    20120813-161006 766 cmd7 - Response: [5] 138-event=2.1
    ...
    20120813-161006 804 cmd7 - Host:server.domain.com/10.176.136.238 closed command interface from port: 3624

    I'm assuming a few things about your log snippet:

    1. You haven't excised any lines from it.
    2. The part in your log that says "210 Service ready" is actually a typo (should be 201).
    3. You are censoring your hostname and you actually do get a fully qualified name such as: "Host:server.domain.com/205.96.136.238"

    I don't know yet what would cause the connection to be dropped immediately the way your log shows :(

    Is the Toolkit error number 2080, 20052, 20053 or 20054? Is "Cannot connect to C-Gate server." the full message with no other text?
     
    Last edited by a moderator: Aug 13, 2012
    daniel, Aug 13, 2012
    #4
  5. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    No lines were cut.
    Guilty as charged, typo by me.
    I didn't edit this bit - 'server.domain.com' wasn't mentioned.
    The error code was 2080 and you are correct, "Cannot connect to the C-Gate server" was the error message. Back to Google...
    I'll let you know if there is any progress.
    No other linux machine to test on.

    Thanks,

    Mark
     
    Mr Mark, Aug 13, 2012
    #5
  6. Mr Mark

    Craggen

    Joined:
    Dec 30, 2009
    Messages:
    26
    Likes Received:
    0
    Location:
    Scotland
    Having found this thread due to experiencing exactly the same issue I was wondering if anyone had found a solution?

    I also am new to Linux but have followed the c-gate deployment guide for linux.

    I'm running on Debian version wheezy/sid and have installed OpenJDK version 1.7.0_07.

    I've specifically opened destination tcp ports for 20123, 20023, 20024, 20025 and 20026.

    When running Toolkit version 1.12.0 from my Windows 7 machine I receive Error 2080.

    On the Linux box the terminal shows.

    Code:
    20121109-201725 803 cmd23 - Host:/192.168.0.103 opened command interface from port: 50717
    20121109-201725 899 sys Debug: New Command Context: cc012 = AccessContext Session /192.168.0.103#24
    20121109-201725 766 cmd23 - Response: 201 Service ready: Clipsal C-Gate Version: v2.9.0 (build 2449) #cmd-syntax=1.0
    20121109-201725 767 cmd23 - commandId= time=29
    20121109-201725 804 cmd23 - Host:/192.168.0.103 closed command interface from port: 50717
    access.txt has been updated with

    Code:
    interface 192.168.255.255 Program
    remote 192.168.255.255 Program
    Have I missed anything?
     
    Craggen, Nov 9, 2012
    #6
  7. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    Linux C-Gate

    Hello Craggen.

    No joy at my end but I haven't tried any further for some time. If there is a change, I'll post.

    Mark
     
    Mr Mark, Nov 9, 2012
    #7
  8. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    Debian image

    Hello daniel.

    Still no joy here on this one. As per your instructions, the file (libjspLux86_64bit.so) was unzipped and installed and the cgate.sh file created. Access text file is OK and works when using a CNI.
    When connecting to c-gate and issuing the 'port list' command, I get the response '126 no ports found'. So.. problem exists on linux side regarding serial port?
    If I send through 'port probe com 1', the response is
    408 Operation failed: Unable to load class:com.clipsal.cgate.cbus.net.CBusComNetwork for network type:COM (com.clipsal.cgate.cbus.net.CBusComNetwork). Is this to be expected when no ports are found or is there something else i need to do?

    Any ideas?

    Mark
     
    Mr Mark, Nov 12, 2012
    #8
  9. Mr Mark

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,346
    Likes Received:
    3
    Location:
    Adelaide, South Australia
    If you search in here you might find the answer.

    Serial ports need additional support to be used from C-Gate (unless there has been an updated in the last couple of years to resolved this).
     
    ashleigh, Nov 12, 2012
    #9
  10. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    Thanks everyone.

    I've tried quite a few things(from this forum and others) to get this one going and recently found someone local who speaks Linux.
    No doubt the answers are just in front of me. Let you know after I catch up with this guy next week.

    Mark
     
    Mr Mark, Nov 14, 2012
    #10
  11. Mr Mark

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    303
    Likes Received:
    1
    Location:
    FNQ
    Java - Toolkit

    I've changed to another flavour of Java (JavaFX) and now all is good!
    C-Gate connectivity via ports 20023, 20025 and Toolkit all works.

    Big thanks to Ingo for pointing me in the right direction.

    PS: this is running on a raspberry pi. Just tonight have loaded Ubuntu onto a 'proper' computer to learn more about the Linux OS.
     
    Last edited by a moderator: Feb 21, 2013
    Mr Mark, Feb 10, 2013
    #11
  12. Mr Mark

    MadMal

    Joined:
    Dec 16, 2009
    Messages:
    53
    Likes Received:
    0
    Location:
    Perth, WA
    Ubuntu Java Serial - those words just dont mix!

    Hi Guys (Daniel, Ashleigh, etc) ...

    I just had to rebuild by Ubuntu box - as you guess, I kept great notes from my last rebuild ... however, am stuck trying to get C-Gate to see the serials ..

    As I am running 12.04 server, I tried this as a 'quick win' .. but no fruit! ... was there an additional missing step? do you still need RXTX, etc?

    dmesg tells me I have connected the PCI (cp210x) as /dev/ttyUSB1.

    I have grabbed the .so you attached and run the java command as root (test mode!) .. and get the following error when trying to connect to the project from toolkit:

    Exception in thread "CBusNetwork.netMachine" java.lang.UnsatisfiedLinkError: Serialio.SerialPortLocal.SerOpenPort(LSerialio/SerialConfig;)I
    at Serialio.SerialPortLocal.SerOpenPort(Native Method)
    at Serialio.SerialPortLocal.open(SerialPortLocal.java:338)
    at Serialio.SerialPortLocal.<init>(SerialPortLocal.java:308)
    at A.a(ProGuard:87)
    at com.clipsal.cgate.cbus.net.CBusSerialNetwork.d(ProGuard:78)
    at cW.aB(ProGuard:803)
    at cW.run(ProGuard:725)
    at java.lang.Thread.run(Thread.java:722)





     
    MadMal, Feb 21, 2013
    #12
  13. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    Hiya,

    Are you using the 32 or 64 bit version of Ubuntu? What java version?

    $ uname -a
    $ java -version

    Try popping the C-Gate dir under your home directory and not running it as root, see if that helps any.

    As far as I know there's no missing step. Back in 2009-2010 we trialled RXTX as an alternative serial library (which is why you may have seen it mentioned in unofficial support channels) but eventually abandoned it for several reasons; it could not handle hot-plug swapping of USB cables, and it was no longer being maintained. SerialIO became the alternative library, and then in Toolkit 1.12.x it became the primary library with javaxcomm reverting to the alternate library.
     
    daniel, Feb 22, 2013
    #13
  14. Mr Mark

    MadMal

    Joined:
    Dec 16, 2009
    Messages:
    53
    Likes Received:
    0
    Location:
    Perth, WA
    Ubuntu 12.04 server x86 (Linux ... 3.2.0-37-generic-pae #58-Ubuntu SMP Thu Jan 24 15:51:02 UTC 2013 i686 i686 i386 GNU/Linux).

    java version "1.7.0_13"
    OpenJDK Runtime Environment (IcedTea7 2.3.6) (7u13-2.3.6-0ubuntu0.12.04.1)
    OpenJDK Server VM (build 23.7-b01, mixed mode)

    I have the latest version of cGate (2.9.4 build 2458) sitting in a directory called /home/cgate .. all files owned cgate:cgate and have written a 'service' script in init.d to start/stop cgate as a service running as the cgate user ...

    Was just using the command line as root for different debugging and check access on ports, etc ...

    Just noticed, the service starts ok and log file suggests all ok .. when I connect with toolkit, go to the project, edit the network - the console gives the following error first:

    Serialio Library: version 10.1.0: build 9218
    Copyright (c) 1996-2010 Serialio.com, All Rights Reserved.
    os.name="Linux" os.arch="i386"
    java.lang.UnsatisfiedLinkError: no jspLux86 in java.library.path: Check that native library jspLux86 is in proper directory

    and then gives the UnsatisfiedLinkError only after saving the network as being serial to ttyUSB1 and then trying to open the network.

    I have no problems using the same CGate server and connecting through it to a CNI ...

    Relevant parts of my init script:
    HOST="$HOSTNAME"
    JAVARE="/usr/bin/java"
    CGATEDIR="/home/cgate"
    CGATEJAR="$CGATEDIR/cgate.jar"
    DEVICE_LIST=`ls -1 /dev/tty* | grep USB | paste -sd ":"`

    Start()
    sudo -ucgate -gcgate $JAVARE -Djava.library.path=$CGATEDIR -DSERIAL_PORT_LIST=$DEVICE_LIST -jar -noverify $CGATEJAR &

    /home/cgate dir:
    drwxrwxrwx 12 cgate cgate 4096 Feb 22 12:03 .
    drwxr-xr-x 7 root root 4096 Jan 11 07:57 ..
    -rwxr--r-- 1 cgate cgate 859136 Nov 8 09:21 CBusServiceControl.dll
    -rwxrw-r-- 1 cgate cgate 3026944 Nov 8 09:21 cgate.exe
    -rwxrwxr-x 1 cgate cgate 2000838 Nov 8 09:31 cgate.jar
    -rw-r--r-- 1 cgate cgate 0 Feb 22 12:03 cgate.lock
    -rwxrwxr-x 1 cgate cgate 471916 Nov 8 09:28 CGateManual.chm
    -rwxrwxr-x 1 cgate cgate 1050586 Nov 8 09:29 CGateManual.pdf
    -rw-r--r-- 1 root root 5 Feb 22 11:54 cgate.pid
    -rwxr--r-- 1 cgate cgate 20480 Nov 8 09:21 CGateServiceEvents.dll
    drwxr-xr-x 2 cgate cgate 4096 Feb 6 09:26 config
    -rw-r--r-- 1 cgate cgate 12722 Feb 22 11:57 event.log
    drwxr-xr-x 2 cgate cgate 4096 Feb 6 09:26 help
    -rwxr--r-- 1 cgate cgate 57344 Nov 8 09:21 jspWin.dll
    drwxr-xr-x 2 cgate cgate 4096 Feb 6 09:26 key
    drwxr-xr-x 3 cgate cgate 4096 Feb 6 09:26 lib
    -rwxr--r-- 1 cgate cgate 30180 Mar 3 2009 libjspLux86_64bit.so
    -rwxrwxr-x 1 cgate cgate 57344 Nov 8 09:21 sspro16.dll
    drwxr-xr-x 2 cgate cgate 4096 Feb 22 11:57 tag
    drwxr-xr-x 2 cgate cgate 4096 Feb 6 09:25 transform
    -rwxrwxr-x 1 cgate cgate 110348 Jan 17 14:37 unins000.dat
    -rwxrwxr-x 1 cgate cgate 715038 Jan 17 14:37 unins000.exe
    drwxr-xr-x 2 cgate cgate 12288 Feb 6 09:25 unitspec
    -rwxrwxr-x 1 cgate cgate 27648 Nov 8 09:21 win32com.dll
    root@xxx:/home/cgate#
     
    Last edited by a moderator: Feb 22, 2013
    MadMal, Feb 22, 2013
    #14
  15. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    Yeah that's 32-bit Linux. I'm afraid I'm going to be pushing you down the rabbit hole here as I haven't tried this one myself.

    I've attached another library file: libjspLux86.so.4.7

    That should be the 32-bit version of the linux serial library.

    Unzip it, drop it in the C-Gate directory. Make sure it's called "libjspLux86.so" ie. rename it to remove the "4.7" (or if you're feeling hardcore create a symbolic link libjspLux86.so -> libjspLux86.so.4.7).

    See how you go with that one.
     

    Attached Files:

    daniel, Feb 22, 2013
    #15
  16. Mr Mark

    MadMal

    Joined:
    Dec 16, 2009
    Messages:
    53
    Likes Received:
    0
    Location:
    Perth, WA
    Looks like that did it .. thanks a lot :)

    yeah, is an old Toshiba laptop I have been playing with and decided to go x86 .. since decided it was the wrong decision for server, but havent had a chance to rebuild again!

    now getting some other error about port in use ..

    20130222-134718 911 //xxx/254 eff50910-5ee0-1030-806a-91f22731ae65 Can't open: C-Bus interface (port in use):/dev/ttyUSB1

    not sure about that one as I dont think I have anything else pointing that way :( ... will have to have a look around!
     
    MadMal, Feb 22, 2013
    #16
  17. Mr Mark

    MadMal

    Joined:
    Dec 16, 2009
    Messages:
    53
    Likes Received:
    0
    Location:
    Perth, WA
    got it ... was a bad error message!

    I added my cgate user into the "dialout" group that was the owner of the /dev/ttyUSB01 device, restarted my service and all going now :)

    so the error message should have been access denied, not device in use!

    thought I would post the reply in case someone else sees the same error and gets stumped!
     
    MadMal, Feb 22, 2013
    #17
  18. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    Thanks for the update, glad everything's working now!
     
    daniel, Feb 24, 2013
    #18
  19. Mr Mark

    cheekymonkey

    Joined:
    Mar 10, 2013
    Messages:
    16
    Likes Received:
    1
    Location:
    Perth, WA
    Just wanted to add to this my findings getting C-Gate running on my machine. It's running Ubuntu 12.04 LTS on an AMD Athlon(tm) 64 X2 Dual Core Processor 5400+

    uname -a reports
    Linux mail 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    Std Java install didn't seem to work, maybe its related to the release note for C-GATE 2.9.2
    0023592 [Libraries] Serial libraries do not work on AMD 64-bit system with 64-bit Java

    In any case I just loaded the 32B version of java
    Code:
    sudo apt-get install openjdk-6-jdk:i386 
    Then tell Ubuntu to use the 32B version
    Code:
     sudo update-alternatives --config java
    Now C-Gate fires up and the Toolkit can connect. I did get stung manually creating the project via a telnet window following http://www.cbusforums.com/forums/showthread.php?t=2350
    The project created fine but when I used the Toolkit to connect it could see all the units but errored out trying to load the programming data, maybe because the network name isn't set.

    btw has anyone got the Diagnostic Utility program to successfully connect?
     
    cheekymonkey, Apr 23, 2013
    #19
  20. Mr Mark

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    761
    Likes Received:
    14
    Location:
    Adelaide
    I suspect you are right. That issue was marked as resolved because the private 32-bit JRE we now deploy on Windows makes this problem (and others) disappear. Explicitly using the 32-bit version of Java on Linux appears to have accomplished the same thing.

    Hard to tell what might be happening here. If you set up level 9 logging you may be able to see what's going on.
     
    Last edited by a moderator: May 2, 2013
    daniel, May 2, 2013
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.