# Modbus

**URL:** <https://forum.xojo.com/t/modbus/31563>\
**Category:** Extras\
**Created:** [May 22, 2016, 2:20pm UTC](https://forum.xojo.com/t/modbus/31563 "2016-05-22T14:20:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaap\_Cammeraat](https://forum.xojo.com/user_avatar/forum.xojo.com/jaap_cammeraat/32/580_2.png) [@Jaap\_Cammeraat](https://forum.xojo.com/u/Jaap_Cammeraat)\
**Post date:** [May 22, 2016, 2:20pm UTC](https://forum.xojo.com/t/modbus/31563/1 "2016-05-22T14:20:47Z")

</div>

Hi, I’m at this moment in the midst of developing some client/server tools with some mobile/desktop Apps!  
The only thing I’m missing is a kind of professional Module/Class or something like that for communication with Modbus RTU and Modbus TCP.

Some questions:

- Do you know about something Modbus within Xojo?
- Do you have it and do you want to share/sell it?
- Do you know how to create a plugin?

Thx!

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [May 22, 2016, 2:23pm UTC](https://forum.xojo.com/t/modbus/31563/2 "2016-05-22T14:23:45Z")

</div>

I did that before. I could add you the CRC function…

---

<div class="post-metadata">

**Author:** ![Jaap\_Cammeraat](https://forum.xojo.com/user_avatar/forum.xojo.com/jaap_cammeraat/32/580_2.png) [@Jaap\_Cammeraat](https://forum.xojo.com/u/Jaap_Cammeraat)\
**Post date:** [May 22, 2016, 2:25pm UTC](https://forum.xojo.com/t/modbus/31563/3 "2016-05-22T14:25:07Z")

</div>

Isn’t it a little bit more than some CRC?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [May 22, 2016, 2:25pm UTC](https://forum.xojo.com/t/modbus/31563/4 "2016-05-22T14:25:51Z")

</div>

you send data packets to the device.  
Those can be easily built with a memoryblock.  
So I did it before for FileMaker.  
The difficult part is the CRC, but I can copy the code to the Xojo plugins.

---

<div class="post-metadata">

**Author:** ![Jaap\_Cammeraat](https://forum.xojo.com/user_avatar/forum.xojo.com/jaap_cammeraat/32/580_2.png) [@Jaap\_Cammeraat](https://forum.xojo.com/u/Jaap_Cammeraat)\
**Post date:** [May 22, 2016, 2:31pm UTC](https://forum.xojo.com/t/modbus/31563/5 "2016-05-22T14:31:34Z")

</div>

CRC would be nice for Lin/Win/Mac of course!

---

<div class="post-metadata">

**Author:** ![Jaap\_Cammeraat](https://forum.xojo.com/user_avatar/forum.xojo.com/jaap_cammeraat/32/580_2.png) [@Jaap\_Cammeraat](https://forum.xojo.com/u/Jaap_Cammeraat)\
**Post date:** [May 22, 2016, 2:35pm UTC](https://forum.xojo.com/t/modbus/31563/6 "2016-05-22T14:35:47Z")

</div>

But a dedicated class for RCU and TCP would be very welcome!  
For me it’s to difficult to understand in a short period of time when I look at [simplymodbus](http://www.simplymodbus.ca/index.html)

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [May 22, 2016, 3:11pm UTC](https://forum.xojo.com/t/modbus/31563/7 "2016-05-22T15:11:26Z")

</div>

[code] dim m as new MemoryBlock(9)

m.UInt8Value(0) = 1 // start of package  
m.UInt8Value(1) = 6 // command code  
m.UInt8Value(2) = 0 // some data…  
m.UInt8Value(3) = 0  
m.UInt8Value(4) = 0  
m.UInt8Value(5) = &h21  
m.UInt8Value(6) = 0 // checksum comes here  
m.UInt8Value(7) = 0  
m.UInt8Value(8) = 4 // end of package

dim Data as string = m.StringValue(0,6)  
dim CheckSum as Int16 = ModBusCalculateRTUMessageCRCMBS(data)

m.UInt16Value(6) = checksum

MsgBox EncodeHex(m)  
[/code]

you build the queries, send them via Socket or SerialPort and parse result.

---

<div class="post-metadata">

**Author:** ![Jaap\_Cammeraat](https://forum.xojo.com/user_avatar/forum.xojo.com/jaap_cammeraat/32/580_2.png) [@Jaap\_Cammeraat](https://forum.xojo.com/u/Jaap_Cammeraat)\
**Post date:** [May 22, 2016, 5:00pm UTC](https://forum.xojo.com/t/modbus/31563/8 "2016-05-22T17:00:08Z")

</div>

Thanks! Tomorrow I will have the right PLC in my office to do some tests!

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:19pm UTC](https://forum.xojo.com/t/modbus/31563/9 "2020-10-29T18:19:51Z")

</div>


