Results 1 to 3 of 3

Thread: TCP/IP comm issue with device

  1. #1

    Unhappy TCP/IP comm issue with device

    I need to communicate with a robot (a BarrettHand) via TCP/IP under Linux. I am not getting it to work.

    I have a Windows-based TCP terminal program called TeraTerm Pro. Using it, my robot responds perfectly. The robot is the server. I send it a motion command "<command>/r", and it moves accordingly. And it sends back the response "<command> =>", as it should, as described in the manual.

    I have Linux code that communicates via TCP/IP with another Windows computer. I just modified that code to try to communicate with my robot. I am getting weird results when I try to use it with my robot.

    Under my Linux code, it responds correctly only to the first command that I send it; it moves correctly and sends back the command plus => appended to the end. But it won't move according to any subsequent commands that I send it. It sends back the "<command> =>", as expected, but it doesn't move. I have to cycle the power on my robot to get it to respond correctly to a new command.

    I'm pretty much positive that the problem is with my TCP/IP communication parameters under Linux, not with the robot itself. I know that I am sending the right commands to the robot. They are exactly the same under both the Linux and Windows code, and it responds perfectly with the Windows code.

    One interesting note: the manual says that it uses "raw" TCP/IP, but the Windows sample code uses "SOCK_STREAM" rather than "SOCK_RAW" in the socket() call. How does that work? Are there other parameters or options that I should change or experiment with?

    How can I make sure that my communication parameters are correct under Linux?

    Signed,

    Golfer

    P.S. I'm a semi-newbie to networking. Please respond accordingly. Thanks!

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    According to the Unix Network Programming book Page 87 There are different combinations of socket type and socket familly, I'll illustrate them here
    Code:
    type / family | AF_INET | AF_INET6 | AF_LOCAL | AF_ROUTE | AF_KEY
    -----------------------------------------------------------------
    SOCK_STREAM   |   TCP   |   TCP    |   YES    |          |  
    SOCK_DGRAM    |   UDP   |   UDP    |   YES    |          |
    SOCK_RAW      |   IPv4  |   IPv6   |          |   YES    |  YES
    Perhaps your combination of those two differs... And you may notice, that TCP is a byte stream, which means it only supports SOCK_STREAM.

    Another thing, you'd might notice the NOTES section of the socket(7) man page:
    Linux will only allow port re-use with the SO_REUSEADDR option when
    this option was set both in the previous program that performed a
    bind() to the port and in the program that wants to re-use the port.
    This differs from some implementations (e.g., FreeBSD) where only the
    later program needs to set the SO_REUSEADDR option. Typically this
    difference is invisible, since, for example, a server program is
    designed to always set this option.
    Perhaps some of your struggles may come from that.

    In order to help further we realy need to know some more, perhaps some packet sniffing to determain if the packets from windows are formed different than the ones from linux, perhaps linux decides to drop your '/r' in the end of the command, which makes the robot understand the commands differently...

    Or maybe I'm just guessing since I have no way of knowing actual setup...
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3

    TCP/IP robot comm not working


    Ok, I think the robot manufacturer told me wrong - I don't think this uses raw IP. I think it's standard TCP/IP, based on what I found in some example Windows code they sent me.

    But I'm still having the same problem. I send it a set of commands, and it will only respond to the first one; I have to cycle the power on the robot to get it to respond to a new command.

    My colleague suggested that the problem may be that it doesn't recognize either the end of the first command or the start of the new one.

    For example, I want to send it a command to initialize (aka "HI") motors one and two. The command for that is "12HI". In order to do that, I send it the following string:
    char command = "12HI\r"

    Is that the correct format to send? Should I include the \r? Or should it be \0 or \n? Or should I delete the \r? That is the string format I was using with the previous version of this robot, which communicated via serial port.

    Or do you think my problem might be something totally different?

    If it will help, I can send you my code. Just let me know.

    Thanks.

    Golfer

Similar Threads

  1. Fedora Core 6 can't comm w network
    By dmonahan in forum Redhat / Fedora
    Replies: 5
    Last Post: 03-14-2007, 03:41 AM
  2. Loopback Device
    By GhostDawg in forum Linux - General Topics
    Replies: 2
    Last Post: 12-24-2006, 04:06 AM
  3. USB Device
    By mugs in forum Linux - Hardware, Networking & Security
    Replies: 6
    Last Post: 08-04-2003, 09:53 AM
  4. DSP-device fsk'd up ;-(
    By Pantheus in forum Linux - General Topics
    Replies: 28
    Last Post: 09-05-2002, 01:13 AM
  5. What are the device names??
    By Compunuts in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 08-24-2002, 05:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •