# modbus with programmable xbee

**URL:** <https://forums.digi.com/t/modbus-with-programmable-xbee/11289>\
**Category:** XBee Programamble (S2C & 900 HP)\
**Created:** [August 5, 2011, 10:24am UTC](https://forums.digi.com/t/modbus-with-programmable-xbee/11289 "2011-08-05T10:24:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankorrigan](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@ankorrigan](https://forums.digi.com/u/ankorrigan)\
**Post date:** [August 5, 2011, 10:24am UTC](https://forums.digi.com/t/modbus-with-programmable-xbee/11289/1 "2011-08-05T10:24:03Z")

</div>

hi all,  
I’d like to use the programmable xbee to make an “xbee-modbusRTU” interface.  
I’m wondering how I can use a modbus library with the freescale microprocessor.  
Is it possible? Is there a preferable library to do this?  
Thank you for answer !

[edit]: here’s a link to an interesting discussion on the subject if u’re interested ^^  
[http://forums.freescale.com/t5/8-Bit-Microcontrollers/Modbus-Protocol-Stack/m-p/22070](http://forums.freescale.com/t5/8-Bit-Microcontrollers/Modbus-Protocol-Stack/m-p/22070)

thus, I’m wondering if I need to modify the bootloader to implement modbus on the “host port”?  
I hope I don’t need to !  
I will receive modbus hexadecimal command Bytes from xbee API, with settings “8N1”(bits/parity/stop bit) , and I 'll just have to modify it to satisfy modbus RTU protocol …

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [August 17, 2011, 2:57pm UTC](https://forums.digi.com/t/modbus-with-programmable-xbee/11289/2 "2011-08-17T14:57:17Z")

</div>

Wow - when it rains, it pours … lots of XBee and Modbus questions in one week 🙂

If your plan is to just answer Modbus/RTU from XBee+API, then you do NOT need Modbus on the serial port.

Your only Modbus protocol chore will be handling the end-of-message issues. Forget the 3.5 char timeout method. Assuming you are only answering a few requests like read holding registers, then after seeing the first 2-3 bytes then you KNOW how long the messages will be.

If the remote is using the Zb fragmentation header, then if it sends 150 bytes, your code will receive a single API frame with all 150 bytes. However, if the remote does NOT use fragmentation, then you WILL receive the message at least 2 API frames with for example 40-70msec gap between.
