How to use Modbus TCP in C++ with libmodbus in Visual Studio 2017

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

ความคิดเห็น • 24

  • @Ackerman-iq3fl
    @Ackerman-iq3fl 2 ปีที่แล้ว +1

    Thanx man !!
    This video helped a lot, now I am able to perform read/write operations..

  • @yutso3177
    @yutso3177 2 ปีที่แล้ว +1

    Thanks for your clear and detailed tutorial. It really helps!!

  • @AbhishekBade1310
    @AbhishekBade1310 6 หลายเดือนก่อน

    weach functions displays an errno when a specific libmodbus functions fails to do its task so i waned to ask whether the string attached to that error is also shown in the output which describes what that errno means? if so how can i add that to the throw in exception handling? thank you.

  • @BillBartol
    @BillBartol ปีที่แล้ว +1

    Very helpful! Thank you!

  • @mb_3000
    @mb_3000 ปีที่แล้ว

    Hi, I used your video to write code for connecting modbus mb3000 and I've managed to connect but I get error saying gateway is unavaliable. Do you have an idea on how to fix this problem?
    I am using vpn connection and only this code to configure the data.

  • @anshuman2952
    @anshuman2952 ปีที่แล้ว

    Thanks a lot for the read function. I would like to ask if there is a function to write to registers through MODBUS as well. If so, how to do that? Thank you.
    Also, is this code only viable for modbus-tcp or can we use it for communication done in modbus rtu as well?

    • @chlow1627
      @chlow1627  ปีที่แล้ว

      Yes, i believe there are functions to read and write modbus registers. And to use for modbus rtu, use modbus_new_rtu() instead of modbus_new_tcp()
      You may find documentation of the library's available functions at the main website. libmodbus.org/
      This build is done using v3.1.7, so documentation is here libmodbus.org/olddocs/v3.1.7/libmodbus
      Do consider supporting the project. :)

    • @anshuman2952
      @anshuman2952 ปีที่แล้ว

      @@chlow1627 Thank you very much for the timely response. It was very helpful.

    • @anshuman2952
      @anshuman2952 ปีที่แล้ว

      Will modbus_connect(mb) return -1 if there is a usb-rs-485 converter connected to a COM port but the converter itself is not connected with any device?

    • @chlow1627
      @chlow1627  11 หลายเดือนก่อน +1

      @@anshuman2952 Hi, sorry for late reply, on my code, it exits with an exception error. Haven't had time to really figured out how to resolve this

    • @anshuman2952
      @anshuman2952 11 หลายเดือนก่อน

      I understand. Thank you very much for trying for my sake.​@@chlow1627

  • @joshuacvzn
    @joshuacvzn 2 ปีที่แล้ว

    I did as shown in the video, but when I compile (minute 15:36) the error appears "undefined reference to `modbus_read_registers', undefined reference to `modbus_strerror', undefined reference to `modbus_new_tcp'...", how can I solve this problem ?
    I'm using Dev C++ because my pc version doesn't work this visual studio

    • @chlow1627
      @chlow1627  2 ปีที่แล้ว

      I would guess your code cannot find the modbus library you included. You may an issue with linking the library to your IDE. Unfortunately, I am not familiar with Dev C++ interface, so you have to look for other tutorials on the linking files within the same folder

  • @AbhishekBade1310
    @AbhishekBade1310 7 หลายเดือนก่อน

    I want to execute a DLL made in cpp using libmodbus inbuilt api's and run that DLL in csharp so is that achievable? If so, then any tips on how I can make that work?

    • @chlow1627
      @chlow1627  7 หลายเดือนก่อน +1

      Unfortunately, I am not too familiar with DLL implementation.
      I believe the repo owner already compiled some sample DLL. Prehaps you could look into repo for that.

    • @stubborn176
      @stubborn176 4 หลายเดือนก่อน

      It is definitely achievable. You just need to make a project in C/C++ that exposes some API, the project will be build as dll project and a C# wrapper over it.

  • @Anas0473
    @Anas0473 ปีที่แล้ว

    I know this is an old video, but i hope you can help.
    I can't get it to run at 10:34 in the video. It gives me 8 errors of unresolved external symbols. I am running the latest version of Visual Studio Community 2022, that being version 17.5.1 and version 3.1.10 of the libmodbus. I would greatly appreciate it if you have any solution to this and are willing to help.

    • @chlow1627
      @chlow1627  ปีที่แล้ว +1

      You are in luck. Maybe more details about the error message?
      I happen to see this. If I recall correctly, I saw unresolved errors when I missed out certain linkages, so maybe step through the video again ?
      Also, Did you include extern "c"?

    • @Anas0473
      @Anas0473 ปีที่แล้ว

      @@chlow1627 I saw it again and figured it out :D
      I got a problem that said something about the preprocessor definitions being undefined. On Google someone said that I could go to C/C++ settings -> Advanced and type disable the specific warning 4996 and it worked.

  • @pere8641
    @pere8641 ปีที่แล้ว

    Thanks !!! Quite useful ! !!!!

  • @joydeeppaul2602
    @joydeeppaul2602 6 หลายเดือนก่อน

    requesting you to share the code

    • @chlow1627
      @chlow1627  6 หลายเดือนก่อน

      It will not work. You really have to set these configurations on your computer

  • @techwishsolutions
    @techwishsolutions ปีที่แล้ว

    thank you!