Moved APDU Timeout and Retries to apdu module.

This commit is contained in:
skarg
2008-08-17 02:12:58 +00:00
parent 0326112c68
commit 9c316a65dc
25 changed files with 79 additions and 173 deletions
+2 -2
View File
@@ -115,7 +115,7 @@ void MyDeviceCommunicationControlSimpleAckHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* handle i-am to support binding to other devices */
@@ -274,7 +274,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
/* loop forever */
+1 -1
View File
@@ -432,7 +432,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
found =
address_bind_request(Target_Device_Object_Instance, &max_apdu,
+5 -41
View File
@@ -127,7 +127,6 @@ static char Description[16] = "server";
/* Protocol_Services_Supported - dynamically generated */
/* Protocol_Object_Types_Supported - in RP encoding */
/* Object_List - dynamically generated */
/* static uint16_t Max_APDU_Length_Accepted = MAX_APDU; - constant */
/* static BACNET_SEGMENTATION Segmentation_Supported = SEGMENTATION_NONE; */
/* static uint8_t Max_Segments_Accepted = 0; */
/* VT_Classes_Supported */
@@ -137,9 +136,6 @@ BACNET_DATE Local_Date; /* rely on OS, if there is one */
/* BACnet UTC is inverse of standard offset - i.e. relative to local */
static int UTC_Offset = 5;
static bool Daylight_Savings_Status = false; /* rely on OS */
/* APDU_Segment_Timeout */
static uint16_t APDU_Timeout = 3000;
static uint8_t Number_Of_APDU_Retries = 3;
/* List_Of_Session_Keys */
/* Time_Synchronization_Recipients */
/* Max_Master - rely on MS/TP subsystem, if there is one */
@@ -341,43 +337,12 @@ uint8_t Device_Protocol_Revision(
return BACNET_PROTOCOL_REVISION;
}
uint16_t Device_Max_APDU_Length_Accepted(
void)
{
return MAX_APDU;
}
BACNET_SEGMENTATION Device_Segmentation_Supported(
void)
{
return SEGMENTATION_NONE;
}
uint16_t Device_APDU_Timeout(
void)
{
return APDU_Timeout;
}
/* in milliseconds */
void Device_Set_APDU_Timeout(
uint16_t timeout)
{
APDU_Timeout = timeout;
}
uint8_t Device_Number_Of_APDU_Retries(
void)
{
return Number_Of_APDU_Retries;
}
void Device_Set_Number_Of_APDU_Retries(
uint8_t retries)
{
Number_Of_APDU_Retries = retries;
}
uint8_t Device_Database_Revision(
void)
{
@@ -842,8 +807,7 @@ int Device_Encode_Property_APDU(
break;
case PROP_MAX_APDU_LENGTH_ACCEPTED:
apdu_len =
encode_application_unsigned(&apdu[0],
Device_Max_APDU_Length_Accepted());
encode_application_unsigned(&apdu[0],MAX_APDU);
break;
case PROP_SEGMENTATION_SUPPORTED:
apdu_len =
@@ -851,11 +815,11 @@ int Device_Encode_Property_APDU(
Device_Segmentation_Supported());
break;
case PROP_APDU_TIMEOUT:
apdu_len = encode_application_unsigned(&apdu[0], APDU_Timeout);
apdu_len = encode_application_unsigned(&apdu[0], apdu_timeout());
break;
case PROP_NUMBER_OF_APDU_RETRIES:
apdu_len =
encode_application_unsigned(&apdu[0], Number_Of_APDU_Retries);
encode_application_unsigned(&apdu[0], apdu_retries());
break;
case PROP_DEVICE_ADDRESS_BINDING:
/* FIXME: encode the list here, if it exists */
@@ -930,7 +894,7 @@ bool Device_Write_Property(
case PROP_NUMBER_OF_APDU_RETRIES:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
/* FIXME: bounds check? */
Device_Set_Number_Of_APDU_Retries((uint8_t) value.type.
apdu_retries_set((uint8_t) value.type.
Unsigned_Int);
status = true;
} else {
@@ -941,7 +905,7 @@ bool Device_Write_Property(
case PROP_APDU_TIMEOUT:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
/* FIXME: bounds check? */
Device_Set_APDU_Timeout((uint16_t) value.type.Unsigned_Int);
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
+2 -2
View File
@@ -174,7 +174,7 @@ static void LocalIAmHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* handle i-am to support binding to other devices */
@@ -326,7 +326,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
/* loop forever */
+1 -1
View File
@@ -307,7 +307,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
found =
address_bind_request(Target_Device_Object_Instance, &max_apdu,
+2 -2
View File
@@ -113,7 +113,7 @@ void MyReinitializeDeviceSimpleAckHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* handle i-am to support binding to other devices */
@@ -268,7 +268,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
/* loop forever */
+2 -2
View File
@@ -85,7 +85,7 @@ void MyRejectHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* set the handler for all the services we don't implement
@@ -230,7 +230,7 @@ int main(int argc, char *argv[]) {
Init_DataLink();
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
timeout_seconds = apdu_timeout() / 1000;
/* send the request */
time(&rawtime);
my_time = localtime(&rawtime);
+2 -2
View File
@@ -88,7 +88,7 @@ void MyRejectHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* set the handler for all the services we don't implement
@@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
Init_DataLink();
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
timeout_seconds = apdu_timeout() / 1000;
/* send the request */
if (argc < 3)
Send_WhoHas_Name(-1, -1, Target_Object_Name);
+1 -1
View File
@@ -294,7 +294,7 @@ int main(int argc, char *argv[]) {
Init_DataLink();
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
timeout_seconds = apdu_timeout() / 1000;
/* send the request */
Send_WhoIs(Target_Object_Instance_Min, Target_Object_Instance_Max);
/* loop forever */
+2 -2
View File
@@ -131,7 +131,7 @@ static void LocalIAmHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* handle i-am to support binding to other devices */
@@ -283,7 +283,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
/* loop forever */
+2 -2
View File
@@ -126,7 +126,7 @@ void MyWritePropertySimpleAckHandler(
static void Init_Service_Handlers(
void)
{
/* we need to handle who-is
/* we need to handle who-is
to support dynamic device binding to us */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* handle i-am to support binding to other devices */
@@ -403,7 +403,7 @@ int main(int argc, char *argv[]) {
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds =
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
(apdu_timeout() / 1000) * apdu_retries();
/* try to bind with the device */
found =
address_bind_request(Target_Device_Object_Instance, &max_apdu,