Corrected compiler warnings.
This commit is contained in:
@@ -66,13 +66,14 @@ void ProcessPT(
|
|||||||
iLen = 0;
|
iLen = 0;
|
||||||
|
|
||||||
/* Decode the block number */
|
/* Decode the block number */
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
&tag_number, &len_value_type);
|
&tag_number, &len_value_type);
|
||||||
iLen += tag_len;
|
iLen += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) { /* Bail out early if wrong type */
|
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||||
data->serviceParametersLen = 0; /* and signal unexpected error */
|
/* Bail out early if wrong type */
|
||||||
|
/* and signal unexpected error */
|
||||||
|
data->serviceParametersLen = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,31 +83,45 @@ void ProcessPT(
|
|||||||
cBlockNumber = (char) ulTemp;
|
cBlockNumber = (char) ulTemp;
|
||||||
if (cBlockNumber < MY_MAX_BLOCK) {
|
if (cBlockNumber < MY_MAX_BLOCK) {
|
||||||
if (data->serviceNumber == MY_SVC_READ) {
|
if (data->serviceNumber == MY_SVC_READ) {
|
||||||
/* Read Response is an unsigned int with 0 for success or a non 0 error code */
|
/* Read Response is an unsigned int with
|
||||||
/* For a successful read the 0 success code is followed by the block number */
|
0 for success or a non 0 error code
|
||||||
/* and then the block contents which consist of 2 unsigned ints (in 0 to 255 */
|
For a successful read the 0 success
|
||||||
/* range as they are really chars) a single precision real and a string which */
|
code is followed by the block number
|
||||||
/* will be up to 32 chars + a nul */
|
and then the block contents which
|
||||||
|
consist of 2 unsigned ints (in 0 to 255
|
||||||
|
range as they are really chars) a single
|
||||||
|
precision real and a string which
|
||||||
|
will be up to 32 chars + a nul */
|
||||||
|
|
||||||
iLen = 0;
|
iLen = 0;
|
||||||
|
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK); /* Signal success */
|
/* Signal success */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen], cBlockNumber); /* Followed by the block number */
|
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK);
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen], MyData[cBlockNumber].cMyByte1); /* And Then the block contents */
|
/* Followed by the block number */
|
||||||
|
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
|
cBlockNumber);
|
||||||
|
/* And Then the block contents */
|
||||||
|
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
|
MyData[(int8_t)cBlockNumber].cMyByte1);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_unsigned(&IOBufferPT[iLen],
|
encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
MyData[cBlockNumber].cMyByte2);
|
MyData[(int8_t)cBlockNumber].cMyByte2);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_real(&IOBufferPT[iLen],
|
encode_application_real(&IOBufferPT[iLen],
|
||||||
MyData[cBlockNumber].fMyReal);
|
MyData[(int8_t)cBlockNumber].fMyReal);
|
||||||
characterstring_init_ansi(&bsTemp, MyData[cBlockNumber].sMyString);
|
characterstring_init_ansi(&bsTemp,
|
||||||
|
(char *)MyData[(int8_t)cBlockNumber].sMyString);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_character_string(&IOBufferPT[iLen],
|
encode_application_character_string(&IOBufferPT[iLen],
|
||||||
&bsTemp);
|
&bsTemp);
|
||||||
} else { /* Write operation */
|
} else {
|
||||||
/* Write block consists of the block number followed by the block contents as */
|
/* Write operation */
|
||||||
/* described above for the read operation. The returned result is an unsigned */
|
/* Write block consists of the block number
|
||||||
/* response which is 0 for success and a non 0 error code otherwise. */
|
followed by the block contents as
|
||||||
|
described above for the read operation.
|
||||||
|
The returned result is an unsigned
|
||||||
|
response which is 0 for success and
|
||||||
|
a non 0 error code otherwise. */
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -119,7 +134,7 @@ void ProcessPT(
|
|||||||
iLen +=
|
iLen +=
|
||||||
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
||||||
&ulTemp);
|
&ulTemp);
|
||||||
MyData[cBlockNumber].cMyByte1 = (char) ulTemp;
|
MyData[(int8_t)cBlockNumber].cMyByte1 = (char) ulTemp;
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -132,7 +147,7 @@ void ProcessPT(
|
|||||||
iLen +=
|
iLen +=
|
||||||
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
||||||
&ulTemp);
|
&ulTemp);
|
||||||
MyData[cBlockNumber].cMyByte2 = (char) ulTemp;
|
MyData[(int8_t)cBlockNumber].cMyByte2 = (char) ulTemp;
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -144,7 +159,7 @@ void ProcessPT(
|
|||||||
}
|
}
|
||||||
iLen +=
|
iLen +=
|
||||||
decode_real(&data->serviceParameters[iLen],
|
decode_real(&data->serviceParameters[iLen],
|
||||||
&MyData[cBlockNumber].fMyReal);
|
&MyData[(int8_t)cBlockNumber].fMyReal);
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -156,13 +171,17 @@ void ProcessPT(
|
|||||||
}
|
}
|
||||||
decode_character_string(&data->serviceParameters[iLen],
|
decode_character_string(&data->serviceParameters[iLen],
|
||||||
len_value_type, &bsTemp);
|
len_value_type, &bsTemp);
|
||||||
strncpy(MyData[cBlockNumber].sMyString, characterstring_value(&bsTemp), MY_MAX_STR); /* Only copy as much as we can accept */
|
/* Only copy as much as we can accept */
|
||||||
MyData[cBlockNumber].sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
strncpy((char *)MyData[(int8_t)cBlockNumber].sMyString,
|
||||||
|
characterstring_value(&bsTemp), MY_MAX_STR);
|
||||||
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK); /* Signal success */
|
/* Make sure it is nul terminated */
|
||||||
|
MyData[(int8_t)cBlockNumber].sMyString[MY_MAX_STR] = '\0';
|
||||||
|
/* Signal success */
|
||||||
|
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_BAD_INDEX); /* Signal bad index */
|
/* Signal bad index */
|
||||||
|
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_BAD_INDEX);
|
||||||
}
|
}
|
||||||
data->serviceParametersLen = iLen;
|
data->serviceParametersLen = iLen;
|
||||||
data->serviceParameters = IOBufferPT;
|
data->serviceParameters = IOBufferPT;
|
||||||
@@ -238,13 +257,19 @@ void handler_conf_private_trans(
|
|||||||
goto CPT_ABORT;
|
goto CPT_ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simple example with service number of 0 for read block and 1 for write block */
|
/* Simple example with service number of 0 for
|
||||||
/* We also only support our own vendor ID. In theory we could support others */
|
read block and 1 for write block
|
||||||
/* for compatability purposes but these interfaces are rarely documented... */
|
We also only support our own vendor ID.
|
||||||
|
In theory we could support others
|
||||||
if ((data.vendorID == BACNET_VENDOR_ID) && (data.serviceNumber <= MY_SVC_WRITE)) { /* We only try to understand our own IDs and service numbers */
|
for compatability purposes but these
|
||||||
ProcessPT(&data); /* Will either return a result block or an app level status block */
|
interfaces are rarely documented... */
|
||||||
if (data.serviceParametersLen == 0) { /* No respopnse means fatal error */
|
if ((data.vendorID == BACNET_VENDOR_ID) &&
|
||||||
|
(data.serviceNumber <= MY_SVC_WRITE)) {
|
||||||
|
/* We only try to understand our own IDs and service numbers */
|
||||||
|
/* Will either return a result block or an app level status block */
|
||||||
|
ProcessPT(&data);
|
||||||
|
if (data.serviceParametersLen == 0) {
|
||||||
|
/* No respopnse means fatal error */
|
||||||
error = true;
|
error = true;
|
||||||
error_class = ERROR_CLASS_SERVICES;
|
error_class = ERROR_CLASS_SERVICES;
|
||||||
error_code = ERROR_CODE_OTHER;
|
error_code = ERROR_CODE_OTHER;
|
||||||
|
|||||||
Reference in New Issue
Block a user