added comments

This commit is contained in:
skarg
2005-06-14 10:35:13 +00:00
parent b2727702d4
commit 4a7139066d
+13 -22
View File
@@ -615,7 +615,6 @@ void AtomicReadFileHandler(
int len = 0; int len = 0;
int pdu_len = 0; int pdu_len = 0;
BACNET_ADDRESS my_address; BACNET_ADDRESS my_address;
bool send = false;
bool error = false; bool error = false;
int bytes_sent = 0; int bytes_sent = 0;
BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT; BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT;
@@ -646,7 +645,6 @@ void AtomicReadFileHandler(
service_data->invoke_id, service_data->invoke_id,
ABORT_REASON_OTHER); ABORT_REASON_OTHER);
fprintf(stderr,"Sending Abort!\n"); fprintf(stderr,"Sending Abort!\n");
send = true;
} }
else if (service_data->segmented_message) else if (service_data->segmented_message)
{ {
@@ -655,7 +653,6 @@ void AtomicReadFileHandler(
service_data->invoke_id, service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED); ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
fprintf(stderr,"Sending Abort!\n"); fprintf(stderr,"Sending Abort!\n");
send = true;
} }
else else
{ {
@@ -663,6 +660,9 @@ void AtomicReadFileHandler(
{ {
data.fileData = (uint8_t *)&buffer[0]; data.fileData = (uint8_t *)&buffer[0];
data.fileDataLength = sizeof(buffer); data.fileDataLength = sizeof(buffer);
// FIXME: this may not be a valid way to check this, as the
// file length may be smaller than the request
// or smaller than the size of the buffer.
if (data.type.stream.requestedOctetCount < data.fileDataLength) if (data.type.stream.requestedOctetCount < data.fileDataLength)
{ {
if (bacfile_read_data(&data)) if (bacfile_read_data(&data))
@@ -671,13 +671,9 @@ void AtomicReadFileHandler(
&Tx_Buf[pdu_len], &Tx_Buf[pdu_len],
service_data->invoke_id, service_data->invoke_id,
&data); &data);
send = true;
} }
else else
{
send = true;
error = true; error = true;
}
} }
else else
{ {
@@ -685,17 +681,17 @@ void AtomicReadFileHandler(
&Tx_Buf[pdu_len], &Tx_Buf[pdu_len],
service_data->invoke_id, service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED); ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
fprintf(stderr,"Sending Abort! %u octets requested. Only able to send %u octets.\n", fprintf(stderr,
"Sending Abort! %u octets requested."
" Only able to send %u octets.\n",
data.type.stream.requestedOctetCount, data.type.stream.requestedOctetCount,
data.fileDataLength); data.fileDataLength);
send = true;
} }
} }
else else
{ {
error_class = ERROR_CLASS_SERVICES; error_class = ERROR_CLASS_SERVICES;
error_code = ERROR_CODE_INVALID_FILE_ACCESS_METHOD; error_code = ERROR_CODE_INVALID_FILE_ACCESS_METHOD;
send = true;
error = true; error = true;
} }
} }
@@ -708,17 +704,13 @@ void AtomicReadFileHandler(
error_class, error_class,
error_code); error_code);
fprintf(stderr,"Sending Error!\n"); fprintf(stderr,"Sending Error!\n");
send = true;
}
if (send)
{
bytes_sent = datalink_send_pdu(
src, // destination address
&Tx_Buf[0],
pdu_len); // number of bytes of data
if (bytes_sent <= 0)
fprintf(stderr,"Failed to send PDU (%s)!\n", strerror(errno));
} }
bytes_sent = datalink_send_pdu(
src, // destination address
&Tx_Buf[0],
pdu_len); // number of bytes of data
if (bytes_sent <= 0)
fprintf(stderr,"Failed to send PDU (%s)!\n", strerror(errno));
return; return;
} }
@@ -726,8 +718,7 @@ void AtomicReadFileHandler(
// We performed an AtomicReadFile Request, // We performed an AtomicReadFile Request,
// and here is the data from the server // and here is the data from the server
// Note: it does not have to be the same file=instance // Note: it does not have to be the same file=instance
// that someone can read from us. It is common to // that someone can read from us.
// use the description as the file name.
void AtomicReadFileAckHandler( void AtomicReadFileAckHandler(
uint8_t *service_request, uint8_t *service_request,
uint16_t service_len, uint16_t service_len,