Added optional 4th parameter to bacawf to control the number of bytes sent in each write of a file.

This commit is contained in:
skarg
2010-02-16 22:47:13 +00:00
parent 24b9e013be
commit b60af74651
+9 -1
View File
@@ -56,6 +56,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/* global variables used in this file */ /* global variables used in this file */
static uint32_t Target_File_Object_Instance = 4194303; static uint32_t Target_File_Object_Instance = 4194303;
static uint32_t Target_Device_Object_Instance = 4194303; static uint32_t Target_Device_Object_Instance = 4194303;
static uint32_t Target_File_Requested_Octet_Count;
static BACNET_ADDRESS Target_Address; static BACNET_ADDRESS Target_Address;
static char *Local_File_Name = NULL; static char *Local_File_Name = NULL;
static bool End_Of_File_Detected = false; static bool End_Of_File_Detected = false;
@@ -177,7 +178,7 @@ int main(
if (argc < 4) { if (argc < 4) {
/* FIXME: what about access method - record or stream? */ /* FIXME: what about access method - record or stream? */
printf("%s device-instance file-instance local-name\r\n", printf("%s device-instance file-instance local-name [octet count]\r\n",
filename_remove_path(argv[0])); filename_remove_path(argv[0]));
return 0; return 0;
} }
@@ -195,6 +196,9 @@ int main(
Target_File_Object_Instance, BACNET_MAX_INSTANCE + 1); Target_File_Object_Instance, BACNET_MAX_INSTANCE + 1);
return 1; return 1;
} }
if (argc > 4) {
Target_File_Requested_Octet_Count = strtol(argv[4], NULL, 0);
}
/* setup my info */ /* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init(); address_init();
@@ -229,6 +233,9 @@ int main(
address_bind_request(Target_Device_Object_Instance, &max_apdu, address_bind_request(Target_Device_Object_Instance, &max_apdu,
&Target_Address); &Target_Address);
if (found) { if (found) {
if (Target_File_Requested_Octet_Count) {
requestedOctetCount = Target_File_Requested_Octet_Count;
} else {
/* calculate the smaller of our APDU size or theirs /* calculate the smaller of our APDU size or theirs
and remove the overhead of the APDU (varies depending on size). and remove the overhead of the APDU (varies depending on size).
note: we could fail if there is a bottle neck (router) note: we could fail if there is a bottle neck (router)
@@ -246,6 +253,7 @@ int main(
requestedOctetCount = my_max_apdu - 64; requestedOctetCount = my_max_apdu - 64;
else else
requestedOctetCount = my_max_apdu / 2; requestedOctetCount = my_max_apdu / 2;
}
/* has the previous invoke id expired or returned? /* has the previous invoke id expired or returned?
note: invoke ID = 0 is invalid, so it will be idle */ note: invoke ID = 0 is invalid, so it will be idle */
if ((invoke_id == 0) || tsm_invoke_id_free(invoke_id)) { if ((invoke_id == 0) || tsm_invoke_id_free(invoke_id)) {