Commit Graph

882 Commits

Author SHA1 Message Date
skarg 7e0dbb7bf7 Fix javadoc header 2019-06-22 13:27:08 +00:00
skarg d7ad240f05 The patch is to change the timeout from 10us to 0 so that we just do a poll for more receive data when there is already data queued. With this patch, the code seems to work just fine with 100Hz timer tick. Thank you, David Mosberger 2019-03-17 22:15:27 +00:00
skarg 2c7d5ea4aa Here is a patch for ports/linux/dlmstp.c that switches it to use CLOCK_MONOTONIC rather than real time for the condition variable. This makes the code robust against changes to real time (say, operator adjust time and moves it back by one year, now the timeout wont fire for a year...). Thank you, David Mosberger 2019-03-17 22:08:25 +00:00
skarg b3c9affd49 Use numeric constants for win32 port defines for MinGW using gcc version 4.8.1 2018-12-18 03:53:12 +00:00
skarg f4984dd8d6 Updated stm32f10x port example to work with IAR EWARM 8.11 2018-12-15 16:52:21 +00:00
skarg 0386af099f Merged revision(s) 3206 from branches/releases/bacnet-stack-0-8-0:
Removed case in MS/TP data expecting reply to not expect a ConfirmedRequest PDU reply. Bug #59. Thank you, Govind!
........
2018-12-13 17:50:25 +00:00
skarg 55794f7f54 Merged revision(s) 3172 from branches/releases/bacnet-stack-0-8-0:
Fixed ReinitializeDevice service error handling of states for demos and ports.
........
2018-12-06 04:11:01 +00:00
skarg c7ed0b24c0 Added address compare API for BIP6. 2018-06-10 02:21:44 +00:00
skarg afd8687519 Updated Makefile GCC ARM build for STM32F10x port. 2018-05-10 18:34:19 +00:00
skarg b0f1107a57 Updated MS/TP FSM to not reply to Broadcast PFM. Thank you, Iqbal Hassan! 2018-03-01 00:08:43 +00:00
skarg 0185fe0314 Fixed Windows compile under MinGW. 2018-02-03 01:22:22 +00:00
skarg 96d222ec58 Added arm-none-eabi GCC Makefile for ports/stm32f10x example 2018-01-21 19:58:16 +00:00
fchaxel e3fab4a96c esp32 support 2017-11-22 07:28:36 +00:00
skarg 0c39a8edaf Clean up compile for Atmel port example. 2017-08-24 17:57:30 +00:00
skarg d39044261c Added some arduino_uno files that we missed during first import [WIP]. 2017-06-26 17:48:02 +00:00
skarg 7d1550362b Merged revision(s) 3136 from branches/releases/bacnet-stack-0-8-0:
Replace Receive_Packet_Flag conditional variable with a semaphore and update the related library functions accordingly.
Analysis of the problem determined that the issue lay in the transfer of APDU packets between the FSM and the APDU packet handler thread.
The mechanism previously used by the FSM to notify the APDU packet handler thread that a packet was available for processing used a pthread conditional variable which packet handler thread was supposed to wait on before being signalled by the FSM.
However the packet handler thread has other tasks to perform and sometimes was not waiting on the conditional variable which it was signalled.
Unlike other synchronisation mechanisms such as semaphores, if the waiting task (the consumer) is not blocked on the conditional variable when the producer signals, then that signal is lost and the consumer is never signalled again, leading to a continual sequence of timeouts on the conditional variable.
This in turn led to the packet handler thread never being notified of a packet waiting to be processed thus causing the interface hang.
The main problem is that a conditional variable is supposed to be used with a mutex to prevent this behaviour occurring, but this mutex was not present (and in fact had been removed from the code, most likely because it was causing other synchronisation issues)
Further inspection revealed that this code was copied from another file but modified to remove the mutex which is an essential part of using a conditional variable for synchronisation. This then prevents the producer task being blocked until the consumer task is waiting on the conditional variable, thus leading to a race condition which is causing the issues seen.
The fix is to replace the conditional variable with a semaphore as this provides the required mechanism in this case.
Thank you Ian Smith at Abelon Systems Ltd. for the patch!

........
2017-06-25 18:08:36 +00:00
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 8af8043d49 Fixed MS/TP ANSWER_DATA_REQUEST state in some of the ports to be compliant to the standard by emitting Reply-Postponed rather than nothing when the data request times out. 2017-05-02 20:17:39 +00:00
skarg bd5ec637a6 Changes to clean up compile warnings 2017-02-14 15:21:39 +00:00
skarg d4469212d0 Updated Atmega8 project to compile under IAR EWARM 6.40.3 2017-01-28 18:43:57 +00:00
skarg 79af8b60df Merged revision(s) 3102 from branches/releases/bacnet-stack-0-8-0:
Changed info prints to go to stdout rather than stderr to clean up Wireshark extcap usage.
........
2017-01-04 18:55:24 +00:00
skarg 18c7020659 Fixed [bug#40] - problems if pdu_len exceeds the size of a single pbuf block. Thank you, Jörg Hofmann!
Added statistics to track packets sent, received, and errors.
Added proper reply when BVLC functions are requested and not supported.
Fixed Forwarded NPDU.
2017-01-02 23:03:10 +00:00
skarg 349c01920f Added MS/TP slave node to BDK DLMSTP module. 2017-01-02 15:47:29 +00:00
skarg d41114b7ca Removed extra RS485 init from main in STM32 port example. Thank you, Sean Monroe! 2016-12-21 18:19:51 +00:00
skarg 63a85eca0d Removed extra LED init from main in STM32 port example. Thank you, Sean Monroe! 2016-12-21 18:11:39 +00:00
skarg 66bf55a302 Adjusted device object local variables in PIC demo to build successfully within given stack frame. 2016-12-14 05:03:30 +00:00
skarg 9699801f32 Added Wireshark 2.x extcap live capture for mstpcap on Linux. 2016-10-30 00:12:09 +00:00
skarg d612ae6567 Some Win32 changes for clean compile of IPv6. 2016-10-25 13:43:14 +00:00
skarg c7147f3805 Fixed ports for Atmega8, Atmega168, and Xmega to compile. 2016-10-25 13:42:13 +00:00
skarg b2938bb68a Changed Device_Object_List_Identifier() to use uint32_t for array_index since that is the size decoded in a ReadProperty request, and unsigned is not always 32-bit. 2016-10-25 13:10:28 +00:00
skarg 88aa9fdb3c BACnet/IPv6 on Win32 port [WIP] 2016-10-03 22:22:34 +00:00
skarg bc61349fe9 Fixed compile errors and warnings for IPv6 on Win32 port. 2016-10-02 21:11:50 +00:00
skarg c9d152bf15 Merged revision(s) 3044 from branches/releases/bacnet-stack-0-8-0:
Added BACnet/IPv6 datalink layer and example BACnet/IPv4 to BACnet/IPv6 router.
BVLC6 layer is working on Linux port without BBMD features yet. Win32 is implemented, untested.
Tested during BACnet North American Plugfest 2016.
........
2016-10-01 20:23:03 +00:00
skarg 10aa414351 Fixed line endings and SVN props with fixup.sh script 2016-09-08 15:56:11 +00:00
skarg bec5836bbd Changed Device_Objects_Property_List() function to pass the object instance so that objects of the same type can have different optional or proprietary properties. 2016-08-12 21:54:02 +00:00
skarg a8ad8f4d5c Changed error code from SERVICE/NO_SPACE_FOR_OBJECT to ABORT/SEGMENTATION_NOT_SUPPORTED to be consistent with the BACnet standard. Thank you, lo pe! [bugs:#41] 2016-08-12 20:45:08 +00:00
skarg aaf9227a0d Merged revision(s) 3018 & 3021 from branches/releases/bacnet-stack-0-8-0:
Updated STM32 DLMSTP module to compile. Some LINT cleanup.
2016-07-19 22:33:17 +00:00
skarg 7462d448a5 Added some fixes to router demo 2016-07-01 14:28:14 +00:00
skarg 3fd93c77d5 Updated the PIC18F6720 port, and added PIC18F97J60 port. Both compile and build but were untested on actual hardware. 2016-05-30 14:55:50 +00:00
skarg 7721c3d9ff Cleaned up some compile warnings by changing PIC compile use large memory model to match the PIC libraries. 2016-05-26 14:58:31 +00:00
skarg 3362eecdff Added security for BACnet stack, based on the BACnet 2012 standard, clause 24.
Implemented the majority of functionalities presented in the standard, but there are several features that this patch currently lacks:
- Set-Master-Key message has a specific order of key adding and decoding which is not covered
- There is no general secure-apdu-handler function
- Checks for the type of keys used for signing/encryption of specific messages is not implemented
- The status of encrypted flag during the calculation of the signature is ambiguous
There is a Linux implementation using the OpenSSL library, with function prototypes broad enough to allow for different implementations.
Thank you, Nikola Jelić!
2016-04-20 17:00:51 +00:00
ekh d09fa006fd Cleanup of MSVC 2015 Community Edition "Properties File" (User Property Manager to explore these). 2016-03-23 18:04:07 +00:00
ekh 6d63f12874 Fixed a few non-relative folder location issues with (only) the Microsoft Visual Studio 2015 port 2016-03-18 07:18:54 +00:00
ekh a8cc153abf Removed compiler transient files from older MSVS 2010 project 2016-03-16 18:06:52 +00:00
ekh 4f0efc6d75 A couple of bugfixes and Microsoft cleanups by Ed 2016-03-15 07:49:22 +00:00
skarg be74823235 Fixed compile of STM32F10x project with IAR-EWARM 7.40. 2016-01-07 21:36:32 +00:00
skarg 0697065030 Fixed some warnings flagged by IAR C-STAT static analysis tool. 2016-01-07 21:31:38 +00:00
skarg dd0fb9c841 Fixed IAR compile errors using IAR EWARM 7.40 2016-01-07 20:53:45 +00:00
ekh 77553982bd Updated vs2015 solution to compile server demo (Compiles and runs under free Microsoft Visual Studio 2015 Community Edition) (Added server project, added "BACnet Solutions Settings" property sheet, included piv.c schedule.c osv.c to BACnet Object Definitions project, added bactimevalue.c to BACnet Stack Library project, compiles runs "Debug/x64"). Removed empty directories and removed old MSVC 2005 and MSVC 2008 projects as obsolete. 2015-12-04 20:44:07 +00:00
skarg 48d04c323f Removed check for NPDU Priority on MS/TP outgoing matching messages since the stack currently doesn't support passing the NDPU Priority through, and every outgoing message is NORMAL. This was causing Reply-Postponed, which is not a good thing for high priority messages. Thank you, Ettore Colicchio! 2015-12-02 20:20:33 +00:00