#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Connecting to an external device via TCP/IP


    Hello all,

    I have an external device which can be controlled from a computer via a dedicated network card and a TCP/IP connection. The device manufacturer supplies software they want you to use to control it, but the software is really terrible, and as there is a 3rd party, open-source alternative, I'm trying to figure out how to control the device myself. Using Wireshark I'm able to see the packets sent in both directions, and they are mostly readable, but I'm having trouble setting up my own connection.

    First, it appears that when the supplier's software isn't open, the computer and device exchange messages around 1-2 times per second, with each subsequent set of messages going to and from consecutive ports on the device's IP address; how do I know which port to connect to?

    Second, when I try to establish a connection (I'm using Matlab's Instrument Control Toolbox, since the program I hope to use to control the device interfaces with Matlab), Matlab fails to do so. The rather unhelpful error message is "connection refused: connect", which appears to be a generic error message returned if any errors occur.

    Does anyone have a suggestion as to how to diagnose the problem, or is there any particular more specific information I should obtain to help do so?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2006
    Location
    Midnight Train Going Anywhere
    Posts
    1,153
    Rep Power
    1598
    What is the device?

    (And why do people never want to give us all the info right away...)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0
    The device is a microscope light source. Basically I just need to be able to send commands to turn on the lamp, set lamp power, open and close the shutter, etc., and get status updates/acknowledgments in return.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    368
    If you have wireshark captures then you need to disseminate the protocol. TCP has a very distinct connection routine, you can limit the wireshark view with filters (SYN would be a useful one here).
    Once you establish that you have the correct connection sequence you need to manage the application-level semantics. You claim that this is mostly 'readable' - does this mean plaintext? If so you should see commands and replies. If there is numeric encoding you will likely need access to some type of manual.
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2006
    Location
    Midnight Train Going Anywhere
    Posts
    1,153
    Rep Power
    1598
    Originally Posted by OlympMicro
    The device is a microscope light source. Basically I just need to be able to send commands to turn on the lamp, set lamp power, open and close the shutter, etc., and get status updates/acknowledgments in return.
    Does it have a name or a model number or even a brand? It's hard to find info and drivers and whatnot without those things.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0
    Many thanks for your responses.

    Originally Posted by ctardi
    Does it have a name or a model number or even a brand? It's hard to find info and drivers and whatnot without those things.
    It's an Olympus MT20, but finding info and drivers isn't really an option; by default, it's controlled via proprietary software which, as I mentioned before but can't really emphasize enough, is really very awful. We've asked our Olympus rep for an SDK, but they won't give it to us, presumably because they want to force all their customers to keep using their software. The connection to the MT20 is through a Realtek RTL8139/810x Family Fast Ethernet NIC (according to ipconfig) inserted in a PCI slot and configured by Olympus. It appears that the computer recognizes a controller on this card as an external network device, and the communication I can see on wireshark takes place between the computer and this card, which then itself controls the lamp.

    Originally Posted by L7Sqr
    If you have wireshark captures then you need to disseminate the protocol. TCP has a very distinct connection routine, you can limit the wireshark view with filters (SYN would be a useful one here).
    Once you establish that you have the correct connection sequence you need to manage the application-level semantics. You claim that this is mostly 'readable' - does this mean plaintext? If so you should see commands and replies. If there is numeric encoding you will likely need access to some type of manual.
    I think my initial problem connecting was due to the fact that I was trying to use the MATLAB Instrument Control toolbox, which only allows you to connect as a client to a server. However, it appears the MT20 wants the computer to be the server (on the bright side, this appears to solve my which-port-do-I-connect-to problem, since I can just accept a connection from the current active port). Using the Python socket module I was able to send and receive data. I'm still working on getting the correct connection/initiation sequence, but the wireshark filters have been quite helpful.
    By 'readable' I meant that the commands and acknowledgments are in XML with fairly intuitive variable names. Since I can send commands using the lousy Olympus software and find the corresponding messages in the captures, I think I should be able to copy them directly into my program. The only thing that might prevent me is that the messages contain a message number, so I might have to parse the messages and insert the current number; perhaps this is why sending copied messages so far hasn't had an effect other than an XML-parsed-successfully reply (i.e., the open/close shutter command doesn't yet open/close the shutter).

    Again, thanks a lot for your help.
  12. #7
  13. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7175
    as there is a 3rd party, open-source alternative
    If there is already an open-source alternative why don't you just modify it instead of starting from scratch? The people who made the open-source alternative must have already done the hard work of deciphering the protocol.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0
    Originally Posted by E-Oreo
    If there is already an open-source alternative why don't you just modify it instead of starting from scratch? The people who made the open-source alternative must have already done the hard work of deciphering the protocol.
    The open-source alternative I mentioned (MicroManager) is a generic package for controlling and programming microscopes. We are using it, but it still needs specific device drivers--of which none are currently available for the MT20--in order to interface with the microscope components.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2017
    Posts
    1
    Rep Power
    0
    Hi, can I ask if you were ultimately successful in communicating and controlling the MT20?

IMN logo majestic logo threadwatch logo seochat tools logo