Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Modbus tcp server example

Discussion in 'Scripting' started by kabouras33, Oct 2, 2019.

  1. kabouras33

    kabouras33

    Joined:
    Feb 16, 2018
    Posts:
    10
    Hello all,
    I am trying to find a simple example for a modbus tcp slave example but i i cannot find anything on google.I could find a master example which works ok but no slave....any clues anyone???
    Thank you very much
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    Isn't that master sends request and slave filters requests and send response accordingly?

    So I think you would need have listener on the slave.

    May I ask, why you are using MODBUS protocol, to communicate between Unity application instances? Is that for industrial hardware simulation purposes, or you want to communicate actually with imdustrial hardware?
     
  3. kabouras33

    kabouras33

    Joined:
    Feb 16, 2018
    Posts:
    10
    Hello!
    Well i am experimenting with a project that i i have a master and a slave of my own (embedded with microchip controllers) and i want to add an android app as a slave also for visual purposes.
    I chose modbus because it is easy to transfer value data from sensors.and it is intended for industry too.
    I think it will be nice to implement all the benefits of unity in such a project.
    As a master its great but it is limites in one screen only but as a slave i can add as many as i want....but there is no example and i dont have the necessary knowledge in c# or unity to started from scratch...
    Thank you very much for your interest!
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    It is because Unity primarily is game maker tool.
    However, I wouldn't be using MODBUS just to communicate between Unity instances. You just need send ID to identify slave. Or in other words a network client. In case of modbus, you may be interested to look into network package structure. I did that so long ago, but if I recall correctly, you need consider little/big endian, and there was also CR check bytes at the end of package. Data in the middle. So you could construct and deconstruct own packages. I suspect you may be aware of that anyway, judging after your other thread.

    However, normally you would be building authorative server and clients solution, just to communicate between Unity game/app instances. Just as typical game. Would be much simpler to handle. And there are tons of supports on the topic.

    I would use modbus protocol only, if as you mentioned, try to communicate directly with industrial hardware, and there is no other means of translating data to TCP/IP/UDP protocols.
     
  5. kabouras33

    kabouras33

    Joined:
    Feb 16, 2018
    Posts:
    10
    Thank you very much!!!!
    But unfortunately yes i i t to communicate with industrial hardware too but i i do dot know any other way of making it....
    If someone has any idea i would appreciate it...
    Thank you very much