diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/bacnet.aps b/bacnet-stack/ports/bdk-atxx4-mstp/bacnet.aps index a625b74d..b00c3f67 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/bacnet.aps +++ b/bacnet-stack/ports/bdk-atxx4-mstp/bacnet.aps @@ -1 +1 @@ -bacnet29-Apr-2009 08:16:5312-Aug-2009 10:45:24241029-Apr-2009 08:16:5344, 15, 0, 623AVR GCCbacnet.elfD:\code\bacnet-stack\ports\bdk-atxx4-mstp\JTAGICE mkIIATmega644P.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.ctimer2.ceeprom.cinit.cinput.cled.crs485.cseeprom.cserial.cstack.cdlmstp.cbo.cbi.cai.cdevice.ch_rp.ch_wp.ctimer.heeprom.hhardware.hiar2gcc.hinit.hinput.hled.hnvdata.hrs485.hseeprom.hserial.hMakefiledefaultYESMakefileatmega644p111bacnet.elfdefault\1-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\WinAVR-20090313\bin\avr-gcc.exeC:\WinAVR-20090313\utils\bin\make.exeD:\code\bacnet-stack\ports\bdk-atxx4-mstp\timer.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\eeprom.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\hardware.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\iar2gcc.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\init.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\input.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\led.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\nvdata.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\rs485.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\seeprom.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\serial.hD:\code\bacnet-stack\ports\bdk-atxx4-mstp\main.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\timer2.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\eeprom.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\init.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\input.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\led.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\rs485.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\seeprom.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\serial.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\stack.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\dlmstp.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\bo.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\bi.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\ai.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\device.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\h_rp.cD:\code\bacnet-stack\ports\bdk-atxx4-mstp\h_wp.c00000main.c100001Makefile1 +bacnet29-Apr-2009 08:16:5311-Feb-2010 10:52:30241029-Apr-2009 08:16:5344, 15, 0, 623AVR GCCbacnet.elfD:\code\bacnet-stack\ports\bdk-atxx4-mstp\JTAGICE mkIIATmega644P.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.ctimer2.ceeprom.cinit.cinput.cled.crs485.cseeprom.cserial.cstack.cdlmstp.cbo.cbi.cai.cdevice.ctimer.heeprom.hhardware.hiar2gcc.hinit.hinput.hled.hnvdata.hrs485.hseeprom.hserial.hMakefiledefaultYESMakefileatmega644p111bacnet.elfdefault\1-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\WinAVR-20090313\bin\avr-gcc.exeC:\WinAVR-20090313\utils\bin\make.exe00000main.c25900001Makefile1 diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/device.c b/bacnet-stack/ports/bdk-atxx4-mstp/device.c index 520d67d1..5635207b 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/device.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/device.c @@ -299,7 +299,6 @@ static const int Device_Properties_Required[] = { static const int Device_Properties_Optional[] = { PROP_DESCRIPTION, - PROP_PROTOCOL_CONFORMANCE_CLASS, -1 }; @@ -460,18 +459,6 @@ uint16_t Device_Vendor_Identifier( return BACNET_VENDOR_ID; } -uint8_t Device_Protocol_Version( - void) -{ - return 1; -} - -uint8_t Device_Protocol_Revision( - void) -{ - return 5; -} - BACNET_SEGMENTATION Device_Segmentation_Supported( void) { @@ -652,8 +639,7 @@ int Device_Read_Property( break; case PROP_VENDOR_IDENTIFIER: apdu_len = - encode_application_unsigned(&apdu[0], - Device_Vendor_Identifier()); + encode_application_unsigned(&apdu[0], BACNET_VENDOR_ID); break; case PROP_MODEL_NAME: characterstring_init_ansi(&char_string, "bdk-atxx4-mstp"); @@ -672,17 +658,11 @@ int Device_Read_Property( break; case PROP_PROTOCOL_VERSION: apdu_len = - encode_application_unsigned(&apdu[0], - Device_Protocol_Version()); + encode_application_unsigned(&apdu[0], 1); break; case PROP_PROTOCOL_REVISION: apdu_len = - encode_application_unsigned(&apdu[0], - Device_Protocol_Revision()); - break; - /* BACnet Legacy Support */ - case PROP_PROTOCOL_CONFORMANCE_CLASS: - apdu_len = encode_application_unsigned(&apdu[0], 1); + encode_application_unsigned(&apdu[0], 5); break; case PROP_PROTOCOL_SERVICES_SUPPORTED: /* Note: list of services that are executed, not initiated. */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/h_rp.c b/bacnet-stack/ports/bdk-atxx4-mstp/h_rp.c deleted file mode 100644 index 695efc40..00000000 --- a/bacnet-stack/ports/bdk-atxx4-mstp/h_rp.c +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** -* -* Copyright (C) 2005 Steve Karg -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -* -*********************************************************************/ -#include -#include -#include -#include -#include -#include "config.h" -#include "txbuf.h" -#include "bacdef.h" -#include "bacdcode.h" -#include "bacerror.h" -#include "apdu.h" -#include "npdu.h" -#include "abort.h" -#include "rp.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "av.h" -#include "bi.h" -#include "bo.h" - -static uint8_t Temp_Buf[MAX_APDU] = { 0 }; - -/* Encodes the property APDU and returns the length, - or sets the error, and returns -1 */ -int Encode_Property_APDU( - uint8_t * apdu, - BACNET_OBJECT_TYPE object_type, - uint32_t object_instance, - BACNET_PROPERTY_ID property, - int32_t array_index, - BACNET_ERROR_CLASS * error_class, - BACNET_ERROR_CODE * error_code) -{ - int apdu_len = -1; - - /* initialize the default return values */ - *error_class = ERROR_CLASS_OBJECT; - *error_code = ERROR_CODE_UNKNOWN_OBJECT; - /* handle each object type */ - switch (object_type) { - case OBJECT_DEVICE: - if (Device_Valid_Object_Instance_Number(object_instance)) { - apdu_len = - Device_Encode_Property_APDU(&apdu[0], object_instance, - property, array_index, error_class, error_code); - } - break; - case OBJECT_ANALOG_INPUT: - if (Analog_Input_Valid_Instance(object_instance)) { - apdu_len = - Analog_Input_Encode_Property_APDU(&apdu[0], - object_instance, property, array_index, error_class, - error_code); - } - break; - case OBJECT_ANALOG_VALUE: - if (Analog_Value_Valid_Instance(object_instance)) { - apdu_len = - Analog_Value_Encode_Property_APDU(&apdu[0], - object_instance, property, array_index, error_class, - error_code); - } - break; - case OBJECT_BINARY_INPUT: - if (Binary_Input_Valid_Instance(object_instance)) { - apdu_len = - Binary_Input_Encode_Property_APDU(&apdu[0], - object_instance, property, array_index, error_class, - error_code); - } - break; - case OBJECT_BINARY_OUTPUT: - if (Binary_Output_Valid_Instance(object_instance)) { - apdu_len = - Binary_Output_Encode_Property_APDU(&apdu[0], - object_instance, property, array_index, error_class, - error_code); - } - break; - default: - *error_class = ERROR_CLASS_OBJECT; - *error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE; - break; - } - - return apdu_len; -} - -void handler_read_property( - uint8_t * service_request, - uint16_t service_len, - BACNET_ADDRESS * src, - BACNET_CONFIRMED_SERVICE_DATA * service_data) -{ - BACNET_READ_PROPERTY_DATA data; - int len = 0; - int pdu_len = 0; - BACNET_NPDU_DATA npdu_data; - bool error = false; - int bytes_sent = 0; - BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT; - BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT; - BACNET_ADDRESS my_address; - - /* encode the NPDU portion of the packet */ - datalink_get_my_address(&my_address); - npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, - &npdu_data); - if (service_data->segmented_message) { - /* we don't support segmentation - send an abort */ - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, - true); - goto RP_ABORT; - } - len = rp_decode_service_request(service_request, service_len, &data); - if (len < 0) { - /* bad decoding - send an abort */ - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, ABORT_REASON_OTHER, true); - goto RP_ABORT; - } - /* most cases will be error */ - error = true; - len = - Encode_Property_APDU(&Temp_Buf[0], data.object_type, - data.object_instance, data.object_property, data.array_index, - &error_class, &error_code); - if (len >= 0) { - /* encode the APDU portion of the packet */ - data.application_data = &Temp_Buf[0]; - data.application_data_len = len; - /* FIXME: probably need a length limitation sent with encode */ - len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, &data); - if (len > service_data->max_resp) { - /* too big for the sender - send an abort */ - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, - true); - goto RP_ABORT; - } else { - error = false; - } - } - if (error) { - if (len == -2) { - /* BACnet APDU too small to fit data, so proper response is Abort */ - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RP_ABORT; - } - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, - error_class, error_code); - } - RP_ABORT: - pdu_len += len; - bytes_sent = - datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], - pdu_len); - - return; -} diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/h_rpm.c b/bacnet-stack/ports/bdk-atxx4-mstp/h_rpm.c deleted file mode 100644 index 819c9ce8..00000000 --- a/bacnet-stack/ports/bdk-atxx4-mstp/h_rpm.c +++ /dev/null @@ -1,447 +0,0 @@ -/************************************************************************** -* -* Copyright (C) 2007 Steve Karg -* Inspired by John Stachler -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -* -*********************************************************************/ - -#include -#include -#include -#include -#include "config.h" -#include "txbuf.h" -#include "memcopy.h" -#include "bacdef.h" -#include "bacdcode.h" -#include "apdu.h" -#include "npdu.h" -#include "abort.h" -#include "rpm.h" -#include "handlers.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "bi.h" -#include "bo.h" - -static uint8_t Temp_Buf[MAX_APDU] = { 0 }; - -struct property_list_t { - const int *pList; - unsigned count; -}; - -struct special_property_list_t { - struct property_list_t Required; - struct property_list_t Optional; - struct property_list_t Proprietary; -}; - -static unsigned property_list_count( - const int *pList) -{ - unsigned property_count = 0; - - if (pList) { - while (*pList != -1) { - property_count++; - pList++; - } - } - - return property_count; -} - -/* for a given object type, returns the special property list */ -static void RPM_Property_List( - BACNET_OBJECT_TYPE object_type, - struct special_property_list_t *pPropertyList) -{ - pPropertyList->Required.pList = NULL; - pPropertyList->Optional.pList = NULL; - pPropertyList->Proprietary.pList = NULL; - switch (object_type) { - case OBJECT_ANALOG_INPUT: - Analog_Input_Property_Lists(&pPropertyList->Required.pList, - &pPropertyList->Optional.pList, - &pPropertyList->Proprietary.pList); - break; - case OBJECT_BINARY_INPUT: - Binary_Input_Property_Lists(&pPropertyList->Required.pList, - &pPropertyList->Optional.pList, - &pPropertyList->Proprietary.pList); - break; - case OBJECT_BINARY_OUTPUT: - Binary_Output_Property_Lists(&pPropertyList->Required.pList, - &pPropertyList->Optional.pList, - &pPropertyList->Proprietary.pList); - break; - case OBJECT_DEVICE: - Device_Property_Lists(&pPropertyList->Required.pList, - &pPropertyList->Optional.pList, - &pPropertyList->Proprietary.pList); - break; - default: - break; - } - /* fill the count */ - if (pPropertyList->Required.pList) { - pPropertyList->Required.count = - property_list_count(pPropertyList->Required.pList); - } else { - pPropertyList->Required.count = 0; - } - if (pPropertyList->Optional.pList) { - pPropertyList->Optional.count = - property_list_count(pPropertyList->Optional.pList); - } else { - pPropertyList->Optional.count = 0; - } - if (pPropertyList->Proprietary.pList) { - pPropertyList->Proprietary.count = - property_list_count(pPropertyList->Proprietary.pList); - } else { - pPropertyList->Proprietary.count = 0; - } - - return; -} - -static int RPM_Object_Property( - struct special_property_list_t *pPropertyList, - BACNET_PROPERTY_ID special_property, - unsigned index) -{ - int property = -1; /* return value */ - unsigned required, optional, proprietary; - - required = pPropertyList->Required.count; - optional = pPropertyList->Optional.count; - proprietary = pPropertyList->Proprietary.count; - if (special_property == PROP_ALL) { - if (index < required) { - property = pPropertyList->Required.pList[index]; - } else if (index < (required + optional)) { - index -= required; - property = pPropertyList->Optional.pList[index]; - } else if (index < (required + optional + proprietary)) { - index -= (required + optional); - property = pPropertyList->Proprietary.pList[index]; - } - } else if (special_property == PROP_REQUIRED) { - if (index < required) { - property = pPropertyList->Required.pList[index]; - } - } else if (special_property == PROP_OPTIONAL) { - if (index < optional) { - property = pPropertyList->Optional.pList[index]; - } - } - - return property; -} - -static unsigned RPM_Object_Property_Count( - struct special_property_list_t *pPropertyList, - BACNET_PROPERTY_ID special_property) -{ - unsigned count = 0; /* return value */ - - if (special_property == PROP_ALL) { - count = - pPropertyList->Required.count + pPropertyList->Optional.count + - pPropertyList->Proprietary.count; - } else if (special_property == PROP_REQUIRED) { - count = pPropertyList->Required.count; - } else if (special_property == PROP_OPTIONAL) { - count = pPropertyList->Optional.count; - } - - return count; -} - -/* Encode the RPM property returning the length of the encoding, - or 0 if there is no room to fit the encoding. */ -int RPM_Encode_Property( - uint8_t * apdu, - uint16_t offset, - uint16_t max_apdu, - BACNET_OBJECT_TYPE object_type, - uint32_t object_instance, - BACNET_PROPERTY_ID object_property, - int32_t array_index) -{ - int len = 0; - size_t copy_len = 0; - int apdu_len = 0; - BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT; - BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT; - - len = - rpm_ack_encode_apdu_object_property(&Temp_Buf[0], object_property, - array_index); - copy_len = memcopy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu); - if (copy_len == 0) { - return 0; - } - apdu_len += len; - len = - Encode_Property_APDU(&Temp_Buf[0], object_type, object_instance, - object_property, array_index, &error_class, &error_code); - if (len < 0) { - /* error was returned - encode that for the response */ - len = - rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0], - error_class, error_code); - copy_len = - memcopy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len, max_apdu); - if (copy_len == 0) { - return 0; - } - } else if ((offset + apdu_len + 1 + len + 1) < max_apdu) { - /* enough room to fit the property value and tags */ - len = - rpm_ack_encode_apdu_object_property_value(&apdu[offset + apdu_len], - &Temp_Buf[0], len); - } else { - /* not enough room - abort! */ - return 0; - } - apdu_len += len; - - return apdu_len; -} - -void handler_read_property_multiple( - uint8_t * service_request, - uint16_t service_len, - BACNET_ADDRESS * src, - BACNET_CONFIRMED_SERVICE_DATA * service_data) -{ - int len = 0; - int copy_len = 0; - int decode_len = 0; - int pdu_len = 0; - BACNET_NPDU_DATA npdu_data; - int bytes_sent; - BACNET_ADDRESS my_address; - BACNET_OBJECT_TYPE object_type; - uint32_t object_instance = 0; - int apdu_len = 0; - int npdu_len = 0; - BACNET_PROPERTY_ID object_property; - int32_t array_index = 0; - - /* jps_debug - see if we are utilizing all the buffer */ - /* memset(&Handler_Transmit_Buffer[0], 0xff, sizeof(Handler_Transmit_Buffer)); */ - /* encode the NPDU portion of the packet */ - datalink_get_my_address(&my_address); - npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - npdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, - &npdu_data); - if (service_data->segmented_message) { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, - true); -#if PRINT_ENABLED - printf("RPM: Segmented message. Sending Abort!\r\n"); -#endif - goto RPM_ABORT; - } - /* decode apdu request & encode apdu reply - encode complex ack, invoke id, service choice */ - apdu_len = - rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id); - do { - len = - rpm_decode_object_id(&service_request[decode_len], - service_len - decode_len, &object_type, &object_instance); - /* end of object? */ - if (len > 0) { - decode_len += len; - } else { - len = - rpm_decode_object_end(&service_request[decode_len], - service_len - decode_len); - if (len == 1) { - decode_len++; - len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]); - copy_len = - memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], - apdu_len, len, sizeof(Handler_Transmit_Buffer)); - if (!copy_len) { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } else { - apdu_len += copy_len; - } - } else { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, ABORT_REASON_OTHER, true); - goto RPM_ABORT; - } - break; - } - len = - rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], object_type, - object_instance); - copy_len = - memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], apdu_len, - len, sizeof(Handler_Transmit_Buffer)); - if (!copy_len) { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } else { - apdu_len += copy_len; - } - /* do each property of this object of the RPM request */ - do { - len = - rpm_decode_object_property(&service_request[decode_len], - service_len - decode_len, &object_property, &array_index); - /* end of property list? */ - if (len > 0) { - decode_len += len; - } else { - len = - rpm_decode_object_end(&service_request[decode_len], - service_len - decode_len); - if (len == 1) { - decode_len++; - len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]); - copy_len = - memcopy(&Handler_Transmit_Buffer[npdu_len], - &Temp_Buf[0], apdu_len, len, - sizeof(Handler_Transmit_Buffer)); - if (!copy_len) { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer - [npdu_len], service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } else { - apdu_len += copy_len; - } - } else { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, ABORT_REASON_OTHER, true); - goto RPM_ABORT; - } - /* stop decoding properties */ - break; - } - /* handle the special properties */ - if ((object_property == PROP_ALL) || - (object_property == PROP_REQUIRED) || - (object_property == PROP_OPTIONAL)) { - struct special_property_list_t property_list; - unsigned property_count = 0; - unsigned index = 0; - BACNET_PROPERTY_ID special_object_property; - - special_object_property = object_property; - RPM_Property_List(object_type, &property_list); - property_count = - RPM_Object_Property_Count(&property_list, - special_object_property); - if (property_count == 0) { - /* handle the error code - but use the special property */ - len = - RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, MAX_APDU, object_type, - object_instance, object_property, array_index); - if (len > 0) { - apdu_len += len; - } else { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer - [npdu_len], service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } - } else { - for (index = 0; index < property_count; index++) { - object_property = - RPM_Object_Property(&property_list, - special_object_property, index); - len = - RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, MAX_APDU, object_type, - object_instance, object_property, array_index); - if (len > 0) { - apdu_len += len; - } else { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer - [npdu_len], service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } - } - } - } else { - /* handle an individual property */ - len = - RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, sizeof(Handler_Transmit_Buffer), - object_type, object_instance, object_property, - array_index); - if (len > 0) { - apdu_len += len; - } else { - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); - goto RPM_ABORT; - } - } - } while (1); - if (decode_len >= service_len) { - break; - } - } while (1); - if (apdu_len > service_data->max_resp) { - /* too big for the sender - send an abort */ - apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, - true); - } - RPM_ABORT: - pdu_len = apdu_len + npdu_len; - bytes_sent = - datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], - pdu_len); -} diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/h_wp.c b/bacnet-stack/ports/bdk-atxx4-mstp/h_wp.c deleted file mode 100644 index be338d44..00000000 --- a/bacnet-stack/ports/bdk-atxx4-mstp/h_wp.c +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************** -* -* Copyright (C) 2005 Steve Karg -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -* -*********************************************************************/ -#include -#include -#include -#include -#include -#include "config.h" -#include "txbuf.h" -#include "bacdef.h" -#include "bacdcode.h" -#include "bacerror.h" -#include "apdu.h" -#include "npdu.h" -#include "abort.h" -#include "wp.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "av.h" -#include "bi.h" -#include "bo.h" - -/* too big to reside on stack frame for PIC */ -static BACNET_WRITE_PROPERTY_DATA wp_data; - -void handler_write_property( - uint8_t * service_request, - uint16_t service_len, - BACNET_ADDRESS * src, - BACNET_CONFIRMED_SERVICE_DATA * service_data) -{ - int len = 0; - int pdu_len = 0; - BACNET_NPDU_DATA npdu_data; - BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT; - BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT; - int bytes_sent = 0; - BACNET_ADDRESS my_address; - - /* encode the NPDU portion of the packet */ - datalink_get_my_address(&my_address); - npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, - &npdu_data); - if (service_data->segmented_message) { - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, - true); - goto WP_ABORT; - } - /* decode the service request only */ - len = wp_decode_service_request(service_request, service_len, &wp_data); - /* bad decoding or something we didn't understand - send an abort */ - if (len <= 0) { - len = - abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, ABORT_REASON_OTHER, true); - goto WP_ABORT; - } - /* handle the object type */ - switch (wp_data.object_type) { - case OBJECT_DEVICE: - if (Device_Write_Property(&wp_data, &error_class, &error_code)) { - len = - encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY); - } else { - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, - error_class, error_code); - } - break; - case OBJECT_ANALOG_INPUT: - case OBJECT_BINARY_INPUT: - error_class = ERROR_CLASS_PROPERTY; - error_code = ERROR_CODE_WRITE_ACCESS_DENIED; - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, - error_class, error_code); - break; - case OBJECT_BINARY_OUTPUT: - if (Binary_Output_Write_Property(&wp_data, &error_class, - &error_code)) { - len = - encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY); - } else { - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, - error_class, error_code); - } - break; - case OBJECT_ANALOG_VALUE: - if (Analog_Value_Write_Property(&wp_data, &error_class, - &error_code)) { - len = - encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY); - } else { - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, - error_class, error_code); - } - break; - default: - len = - bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, - error_class, error_code); - break; - } - WP_ABORT: - pdu_len += len; - bytes_sent = - datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], - pdu_len); - - return; -} diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/main.c b/bacnet-stack/ports/bdk-atxx4-mstp/main.c index bce382ac..49f1cd96 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/main.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/main.c @@ -170,7 +170,6 @@ void test_task( { char buffer[32] = "BACnet: 0000000\r\n"; uint8_t nbytes = 17; - char *pBuffer = NULL; uint8_t data_register = 0; if (timer_elapsed_seconds(TIMER_TEST, 1)) { @@ -205,26 +204,6 @@ void test_task( Binary_Output_Level_Set(1, 1, BINARY_NULL); Binary_Output_Level_Sync(1); } - if (data_register == 'm') { - sprintf(buffer, "->Master State: "); - nbytes = (uint8_t) strlen(buffer); - serial_bytes_send((uint8_t *) buffer, nbytes); - extern char *dlmstp_master_state_text( - void); - pBuffer = dlmstp_master_state_text(); - nbytes = (uint8_t) strlen(pBuffer); - serial_bytes_send((uint8_t *) pBuffer, nbytes); - } - if (data_register == 'r') { - sprintf(buffer, "->Receive State: "); - nbytes = (uint8_t) strlen(buffer); - serial_bytes_send((uint8_t *) buffer, nbytes); - extern char *dlmstp_receive_state_text( - void); - pBuffer = dlmstp_receive_state_text(); - nbytes = (uint8_t) strlen(pBuffer); - serial_bytes_send((uint8_t *) pBuffer, nbytes); - } serial_byte_send('\r'); serial_byte_send('\n'); serial_byte_transmit_complete();