Corrected signed value decoding for signed16 and signed8.
This commit is contained in:
+9
-6
@@ -90,6 +90,8 @@ int awf_decode_service_request(uint8_t * apdu,
|
|||||||
int tag_len = 0;
|
int tag_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
|
int32_t signed_value = 0;
|
||||||
|
uint32_t unsigned_value = 0;
|
||||||
int type = 0; /* for decoding */
|
int type = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
@@ -111,8 +113,8 @@ int awf_decode_service_request(uint8_t * apdu,
|
|||||||
len += tag_len;
|
len += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT)
|
if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT)
|
||||||
return -1;
|
return -1;
|
||||||
len += decode_signed(&apdu[len],
|
len += decode_signed(&apdu[len], len_value_type, &signed_value);
|
||||||
len_value_type, &data->type.stream.fileStartPosition);
|
data->type.stream.fileStartPosition = signed_value;
|
||||||
/* fileData */
|
/* fileData */
|
||||||
tag_len = decode_tag_number_and_value(&apdu[len],
|
tag_len = decode_tag_number_and_value(&apdu[len],
|
||||||
&tag_number, &len_value_type);
|
&tag_number, &len_value_type);
|
||||||
@@ -135,16 +137,17 @@ int awf_decode_service_request(uint8_t * apdu,
|
|||||||
len += tag_len;
|
len += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT)
|
if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT)
|
||||||
return -1;
|
return -1;
|
||||||
len += decode_signed(&apdu[len],
|
len += decode_signed(&apdu[len], len_value_type, &signed_value);
|
||||||
len_value_type, &data->type.record.fileStartRecord);
|
data->type.record.fileStartRecord = signed_value;
|
||||||
/* returnedRecordCount */
|
/* returnedRecordCount */
|
||||||
tag_len = decode_tag_number_and_value(&apdu[len],
|
tag_len = decode_tag_number_and_value(&apdu[len],
|
||||||
&tag_number, &len_value_type);
|
&tag_number, &len_value_type);
|
||||||
len += tag_len;
|
len += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT)
|
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT)
|
||||||
return -1;
|
return -1;
|
||||||
len += decode_unsigned(&apdu[len],
|
len += decode_unsigned(&apdu[len], len_value_type,
|
||||||
len_value_type, &data->type.record.returnedRecordCount);
|
&unsigned_value);
|
||||||
|
data->type.record.returnedRecordCount = unsigned_value;
|
||||||
/* fileData */
|
/* fileData */
|
||||||
tag_len = decode_tag_number_and_value(&apdu[len],
|
tag_len = decode_tag_number_and_value(&apdu[len],
|
||||||
&tag_number, &len_value_type);
|
&tag_number, &len_value_type);
|
||||||
|
|||||||
@@ -1371,18 +1371,13 @@ int encode_context_enumerated(uint8_t * apdu, int tag_number, int value)
|
|||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int decode_signed(uint8_t * apdu, uint32_t len_value, int32_t * value)
|
int decode_signed(uint8_t * apdu, uint32_t len_value, int32_t * value)
|
||||||
{
|
{
|
||||||
int8_t signed8_value = 0;
|
|
||||||
int16_t signed16_value = 0;
|
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
switch (len_value) {
|
switch (len_value) {
|
||||||
case 1:
|
case 1:
|
||||||
decode_signed8(&apdu[0], value);
|
decode_signed8(&apdu[0], value);
|
||||||
*value = signed8_value;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
decode_signed16(&apdu[0], value);
|
decode_signed16(&apdu[0], value);
|
||||||
*value = signed16_value;
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
decode_signed24(&apdu[0], value);
|
decode_signed24(&apdu[0], value);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "txbuf.h"
|
#include "txbuf.h"
|
||||||
#include "bacdef.h"
|
#include "bacdef.h"
|
||||||
|
#include "bacstr.h"
|
||||||
#include "bacerror.h"
|
#include "bacerror.h"
|
||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
@@ -111,6 +112,11 @@ void handler_atomic_write_file(uint8_t * service_request,
|
|||||||
error = true;
|
error = true;
|
||||||
} else if (data.access == FILE_STREAM_ACCESS) {
|
} else if (data.access == FILE_STREAM_ACCESS) {
|
||||||
if (bacfile_write_stream_data(&data)) {
|
if (bacfile_write_stream_data(&data)) {
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr, "AWF: Stream offset %d, %d bytes\n",
|
||||||
|
data.type.stream.fileStartPosition,
|
||||||
|
octetstring_length(&data.fileData));
|
||||||
|
#endif
|
||||||
len =
|
len =
|
||||||
awf_ack_encode_apdu(&Handler_Transmit_Buffer
|
awf_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
[pdu_len], service_data->invoke_id, &data);
|
||||||
|
|||||||
Reference in New Issue
Block a user