Commit Graph

15 Commits

Author SHA1 Message Date
skarg 0b5a514cf7 Adds two new functions to the ring buffer implementation, one to walk the ring by getting a pointer to the next element in the ring, and the other to Pop (remove) a specified element from somewhere in the ring and then move any elements up towards the head to fill the gap left. With these new functions in place, the Linux MS/TP datalink MSTP_Get_Reply() has been updated to walk the ring buffer to try to find the matching reply. If it is found then it is processed in the same way as usual, and then removed from the ring.
When a packet is received which expects a reply a copy is stored in the PDU ring buffer so it can be matched with the reply. Unfortunately when the reply is received it is only checked against the first entry in the ring buffer. This can cause a failure if a second packet expecting a reply has been received while waiting for the first reply to arrive.
This is a known issue in the bacnet-stack open source stack, and there is a outstanding FIXME in the latest version of the source code:

        /* The ANSWER_DATA_REQUEST state is entered when a  */
        /* BACnet Data Expecting Reply, a Test_Request, or  */
        /* a proprietary frame that expects a reply is received. */
        /* FIXME: MSTP_Get_Reply waits for a matching reply, but
           if the next queued message doesn't match, then we
           sit here for Treply_delay doing nothing */

The fix for this is to check all the messages in the PDU queue to see if any of them match, and if one does then handle it in the normal way. Thank you to Ian Smith of Abelon Systems Ltd. for the patch!
2017-06-25 18:06:27 +00:00
skarg f2b754336d Updated ringbuffer library to remove alloc and include data-peek and data-put. 2017-01-01 05:20:13 +00:00
skarg 07bf4eba3b Deprecated Ringbuf_Alloc, and replaced with Ringbuf_Data_Peek() and Ringbuf_Data_Put() functions. Ringbuf_Alloc() was not interrupt or thread safe. 2015-09-09 14:54:02 +00:00
skarg ba3242aafd indented using indent.sh script to get uniform looking code for release 2013-03-13 22:17:13 +00:00
skarg cf882642a8 Changed Ringbuf API: Ringbuf_Pop_Front is now Ringbuf_Pop, and now it copies the buffer into parameter and returns boolean. Original method was not safe since it returned a pointer to the element but freed the buffer element. Changed Ringbuf_Get_Front to Ringbuf_Peek with no change in functionality, to make names more consistent.
Updated all the MS/TP datalink layer implementations that use Ringbuf library.
2013-01-08 20:48:34 +00:00
skarg 48e2c60ce2 indented to standard from script 2012-05-13 15:07:12 +00:00
skarg f6096f6a4d Unified the licenses on header files since we don't have any inline functions or macros with substantial bodies. Per RMS: "Our view is that just using structure definitions, typedefs, enumeration constants, macros with simple bodies, etc., is NOT enough to make a derivative work. It would take a substantial amount of code (coming from inline functions or macros with substantial bodies) to do that." 2012-04-18 16:15:59 +00:00
skarg 2e6a060b26 Added volatile qualifier to ringbuffer library to be interrupt safe. 2012-02-10 22:10:17 +00:00
skarg 6c5fe45769 Changed buffer from volatile pointers to non-volatile data, to pointers to volatile variables. 2012-01-25 19:03:54 +00:00
skarg 4a779febca Added some volatile keywords to make it interrupt safe. 2011-10-18 02:24:44 +00:00
skarg 710cfccfef Indented using indent script. 2010-05-04 21:06:26 +00:00
skarg 35f0a52d51 Exposed some useful functions in FIFO library. Updated Ringbuffer library to my latest. 2010-03-22 21:36:27 +00:00
skarg dc2a432a65 Added alloc to ringbuf module. 2009-12-18 04:20:44 +00:00
skarg 411d6c1b24 Indented. 2007-11-29 15:56:53 +00:00
skarg a2506536ed Moved header files into the include directory. Moved source files into the src directory. Still need to updated the makefiles and projects. 2007-10-10 03:34:37 +00:00