From 2917c9abf0ed0873e8d08a109ac64fa9eb9f8e9b Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 24 Oct 2009 15:49:00 +0000 Subject: [PATCH] Converted C++ comments to C comments --- bacnet-stack/demo/handler/h_pt.c | 62 ++++++++++++------------- bacnet-stack/demo/handler/h_pt_a.c | 24 +++++----- bacnet-stack/demo/handler/s_ptransfer.c | 8 ++-- bacnet-stack/demo/mstpcap/main.c | 10 ++-- bacnet-stack/demo/ptransfer/main.c | 16 +++---- bacnet-stack/include/mydata.h | 2 +- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/bacnet-stack/demo/handler/h_pt.c b/bacnet-stack/demo/handler/h_pt.c index d5d6e1bb..84ac736b 100644 --- a/bacnet-stack/demo/handler/h_pt.c +++ b/bacnet-stack/demo/handler/h_pt.c @@ -34,7 +34,7 @@ #include "apdu.h" #include "npdu.h" #include "abort.h" -//#include "arf.h" +/*#include "arf.h" */ /* demo objects */ #include "device.h" #include "ai.h" @@ -50,12 +50,12 @@ DATABLOCK MyData[MYMAXBLOCK]; -uint8_t IOBufferPT[MAX_APDU]; // Buffer for building response in +uint8_t IOBufferPT[MAX_APDU]; /* Buffer for building response in */ void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data) { - int iLen; // Index to current location in data + int iLen; /* Index to current location in data */ char cBlockNumber; uint32_t ulTemp; int tag_len; @@ -65,12 +65,12 @@ void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data) iLen = 0; - // Decode the block number + /* Decode the block number */ tag_len = decode_tag_number_and_value(&data->serviceParameters[iLen], &tag_number, &len_value_type); iLen += tag_len; - if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) { // Bail out early if wrong type - data->serviceParametersLen = 0; // and signal unexpected error + if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) { /* Bail out early if wrong type */ + data->serviceParametersLen = 0; /* and signal unexpected error */ return; } @@ -78,26 +78,26 @@ void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data) cBlockNumber = (char)ulTemp; if(cBlockNumber < MY_MAX_BLOCK) { if(data->serviceNumber == MY_SVC_READ) { - // Read Response is an unsigned int with 0 for success or a non 0 error code - // For a successful read the 0 success code is followed by the block number - // 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 + /* Read Response is an unsigned int with 0 for success or a non 0 error code */ + /* For a successful read the 0 success code is followed by the block number */ + /* 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 += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK); // Signal success - iLen += encode_application_unsigned(&IOBufferPT[iLen], cBlockNumber); // Followed by the block number - iLen += encode_application_unsigned(&IOBufferPT[iLen], MyData[cBlockNumber].cMyByte1); // And Then the block contents + iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK); /* Signal success */ + iLen += encode_application_unsigned(&IOBufferPT[iLen], cBlockNumber); /* Followed by the block number */ + iLen += encode_application_unsigned(&IOBufferPT[iLen], MyData[cBlockNumber].cMyByte1); /* And Then the block contents */ iLen += encode_application_unsigned(&IOBufferPT[iLen], MyData[cBlockNumber].cMyByte2); iLen += encode_application_real(&IOBufferPT[iLen], MyData[cBlockNumber].fMyReal); characterstring_init_ansi(&bsTemp, MyData[cBlockNumber].sMyString); iLen += encode_application_character_string(&IOBufferPT[iLen], &bsTemp); } - else { // Write operation - // Write block consists of the block number 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. + else { /* Write operation */ + /* Write block consists of the block number 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 = decode_tag_number_and_value(&data->serviceParameters[iLen], &tag_number, &len_value_type); iLen += tag_len; @@ -132,14 +132,14 @@ void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data) return; } decode_character_string(&data->serviceParameters[iLen], len_value_type, &bsTemp); - strncpy(MyData[cBlockNumber].sMyString, characterstring_value(&bsTemp), MY_MAX_STR); // Only copy as much as we can accept - MyData[cBlockNumber].sMyString[MY_MAX_STR] = '\0'; // Make sure it is nul terminated + strncpy(MyData[cBlockNumber].sMyString, characterstring_value(&bsTemp), MY_MAX_STR); /* Only copy as much as we can accept */ + MyData[cBlockNumber].sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */ - iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK); // Signal success + iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK); /* Signal success */ } } else { - iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_BAD_INDEX); // Signal bad index + iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_BAD_INDEX); /* Signal bad index */ } data->serviceParametersLen = iLen; data->serviceParameters = IOBufferPT; @@ -182,8 +182,8 @@ void handler_conf_private_trans( #if PRINT_ENABLED fprintf(stderr,"Received Confirmed Private Transfer Request!\n"); #endif - // encode the NPDU portion of the response packet as it will be needed - // no matter what the outcome. + /* encode the NPDU portion of the response packet as it will be needed */ + /* no matter what the outcome. */ datalink_get_my_address(&my_address); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); @@ -209,13 +209,13 @@ void handler_conf_private_trans( goto CPT_ABORT; } -// Simple example with service number of 0 for read block and 1 for write block -// We also only support our own vendor ID. In theory we could support others -// for compatability purposes but these interfaces are rarely documented... +/* Simple example with service number of 0 for read block and 1 for write block */ +/* We also only support our own vendor ID. In theory we could support others */ +/* for compatability purposes but these interfaces are rarely documented... */ - if((data.vendorID == BACNET_VENDOR_ID) && (data.serviceNumber <= MY_SVC_WRITE)){ // We only try to understand our own IDs and service numbers - ProcessPT(&data); // Will either return a result block or an app level status block - 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 */ + ProcessPT(&data); /* Will either return a result block or an app level status block */ + if(data.serviceParametersLen == 0){ /* No respopnse means fatal error */ error = true; error_class = ERROR_CLASS_SERVICES; error_code = ERROR_CODE_OTHER; @@ -225,7 +225,7 @@ void handler_conf_private_trans( } len = ptransfer_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data); } -else // Not our vendor ID or bad service parameter +else /* Not our vendor ID or bad service parameter */ { error = true; error_class = ERROR_CLASS_SERVICES; diff --git a/bacnet-stack/demo/handler/h_pt_a.c b/bacnet-stack/demo/handler/h_pt_a.c index 9818cc5b..73d0c8ae 100644 --- a/bacnet-stack/demo/handler/h_pt_a.c +++ b/bacnet-stack/demo/handler/h_pt_a.c @@ -34,7 +34,7 @@ #include "apdu.h" #include "npdu.h" #include "abort.h" -//#include "arf.h" +/*#include "arf.h" */ /* demo objects */ #include "device.h" #include "ai.h" @@ -45,7 +45,7 @@ #include "bacfile.h" #endif -extern uint8_t IOBufferPT[300]; // Somewhere to build the encoded result block for Private Transfers +extern uint8_t IOBufferPT[300]; /* Somewhere to build the encoded result block for Private Transfers */ void DecodeBlock(char cBlockNum, uint8_t *pData) @@ -94,7 +94,7 @@ void DecodeBlock(char cBlockNum, uint8_t *pData) iLen += decode_character_string(&pData[iLen], len_value_type, &bsName); strncpy(Response.sMyString, characterstring_value(&bsName), MY_MAX_STR); - Response.sMyString[MY_MAX_STR] = '\0'; // Make sure it is nul terminated + Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */ printf("Private Transfer Read Block Response\n"); printf("Data Block: %d\n", (int)cBlockNum); @@ -109,7 +109,7 @@ void DecodeBlock(char cBlockNum, uint8_t *pData) void ProcessPTA(BACNET_PRIVATE_TRANSFER_DATA *data) { - int iLen; // Index to current location in data + int iLen; /* Index to current location in data */ uint32_t uiErrorCode; char cBlockNumber; uint32_t ulTemp; @@ -119,7 +119,7 @@ void ProcessPTA(BACNET_PRIVATE_TRANSFER_DATA *data) iLen = 0; - // Error code is returned for read and write operations + /* Error code is returned for read and write operations */ tag_len = decode_tag_number_and_value(&data->serviceParameters[iLen], &tag_number, &len_value_type); iLen += tag_len; @@ -131,11 +131,11 @@ void ProcessPTA(BACNET_PRIVATE_TRANSFER_DATA *data) } iLen += decode_unsigned(&data->serviceParameters[iLen], len_value_type, &uiErrorCode); - if(data->serviceNumber == MY_SVC_READ) { // Read I/O block so should be full block of data or error - // Decode the error type and if necessary block number and then fetch the info + if(data->serviceNumber == MY_SVC_READ) { /* Read I/O block so should be full block of data or error */ + /* Decode the error type and if necessary block number and then fetch the info */ if(uiErrorCode == MY_ERR_OK) { - // Block Number + /* Block Number */ tag_len = decode_tag_number_and_value(&data->serviceParameters[iLen], &tag_number, &len_value_type); iLen += tag_len; if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) { @@ -149,12 +149,12 @@ void ProcessPTA(BACNET_PRIVATE_TRANSFER_DATA *data) cBlockNumber = (char)ulTemp; DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]); } - else { // Read error + else { /* Read error */ printf("Private Transfer read operation returned error code: %u\n", uiErrorCode); return; } } - else { // Write I/O block - should just be an OK type message + else { /* Write I/O block - should just be an OK type message */ printf("Private Transfer write operation returned error code: %u\n", uiErrorCode); } } @@ -194,7 +194,7 @@ void handler_conf_private_trans_ack( printf("Received Confirmed Private Transfer Ack!\n"); #endif - len = ptransfer_decode_service_request(service_request, service_len, &data); // Same decode for ack as for service request! + len = ptransfer_decode_service_request(service_request, service_len, &data); /* Same decode for ack as for service request! */ if (len < 0) { #if PRINT_ENABLED @@ -202,7 +202,7 @@ void handler_conf_private_trans_ack( #endif } - ProcessPTA(&data); // See what to do with the response + ProcessPTA(&data); /* See what to do with the response */ return; } diff --git a/bacnet-stack/demo/handler/s_ptransfer.c b/bacnet-stack/demo/handler/s_ptransfer.c index 50d99152..47f3462a 100644 --- a/bacnet-stack/demo/handler/s_ptransfer.c +++ b/bacnet-stack/demo/handler/s_ptransfer.c @@ -64,7 +64,7 @@ uint8_t Send_Private_Transfer_Request( int pdu_len = 0; int bytes_sent = 0; BACNET_NPDU_DATA npdu_data; - static uint8_t pt_req_buffer[300]; // Somewhere to build the request packet + static uint8_t pt_req_buffer[300]; /* Somewhere to build the request packet */ BACNET_PRIVATE_TRANSFER_DATA pt_block; BACNET_CHARACTER_STRING bsTemp; @@ -90,12 +90,12 @@ uint8_t Send_Private_Transfer_Request( pt_block.serviceNumber = service_number; if(service_number == MY_SVC_READ) { - len += encode_application_unsigned(&pt_req_buffer[len], block_number); // The block number we want to retrieve + len += encode_application_unsigned(&pt_req_buffer[len], block_number); /* The block number we want to retrieve */ } else { - len += encode_application_unsigned(&pt_req_buffer[len], block_number); // The block number - len += encode_application_unsigned(&pt_req_buffer[len], block->cMyByte1); // And Then the block contents + len += encode_application_unsigned(&pt_req_buffer[len], block_number); /* The block number */ + len += encode_application_unsigned(&pt_req_buffer[len], block->cMyByte1); /* And Then the block contents */ len += encode_application_unsigned(&pt_req_buffer[len], block->cMyByte2); len += encode_application_real(&pt_req_buffer[len], block->fMyReal); characterstring_init_ansi(&bsTemp, block->sMyString); diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index 85cc328c..aba38971 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -309,11 +309,11 @@ size_t data_write(const void *ptr, size_t size, size_t nitems) { DWORD cbWritten = 0; (void)WriteFile( - hPipe, // handle to pipe - ptr, // buffer to write from - size*nitems, // number of bytes to write - &cbWritten, // number of bytes written - NULL); // not overlapped I/O + hPipe, /* handle to pipe */ + ptr, /* buffer to write from */ + size*nitems, /* number of bytes to write */ + &cbWritten, /* number of bytes written */ + NULL); /* not overlapped I/O */ return fwrite(ptr, size, nitems, pFile); } diff --git a/bacnet-stack/demo/ptransfer/main.c b/bacnet-stack/demo/ptransfer/main.c index bb9381c6..5188deee 100644 --- a/bacnet-stack/demo/ptransfer/main.c +++ b/bacnet-stack/demo/ptransfer/main.c @@ -90,7 +90,7 @@ static void MyErrorHandler( printf("BACnet Error: %s: %s\r\n", bactext_error_class_name((int) error_class), bactext_error_code_name((int) error_code)); -// Error_Detected = true; +/* Error_Detected = true; */ } void MyAbortHandler( @@ -241,7 +241,7 @@ int main( } /* at least one second has passed */ if (current_seconds != last_seconds) { - putchar('.'); // Just to show that time is passing... + putchar('.'); /* Just to show that time is passing... */ last_seconds = current_seconds; tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); } @@ -287,9 +287,9 @@ int main( found = address_bind_request(Target_Device_Object_Instance, &max_apdu, &Target_Address); if (found) { - if (invoke_id == 0) { // Safe to send a new request + if (invoke_id == 0) { /* Safe to send a new request */ switch(iType) { - case 0: // Write blocks to server + case 0: /* Write blocks to server */ NewData.cMyByte1 = iCount; NewData.cMyByte2 = 255 - iCount; NewData.fMyReal = (float)iCount; @@ -299,14 +299,14 @@ int main( invoke_id = Send_Private_Transfer_Request(Target_Device_Object_Instance, BACNET_VENDOR_ID, 1, iCount, &NewData); break; - case 1: // Read blocks from server + case 1: /* Read blocks from server */ printf("Requesting block %d\n", iCount); invoke_id = Send_Private_Transfer_Request(Target_Device_Object_Instance, BACNET_VENDOR_ID, 0, iCount, &NewData); break; - case 2: // Generate some error responses + case 2: /* Generate some error responses */ switch(iCount) { - case 0: // Bad service number i.e. 2 + case 0: /* Bad service number i.e. 2 */ case 2: case 4: case 6: @@ -315,7 +315,7 @@ int main( invoke_id = Send_Private_Transfer_Request(Target_Device_Object_Instance, BACNET_VENDOR_ID, 2, iCount, &NewData); break; - case 1: // Bad vendor ID number + case 1: /* Bad vendor ID number */ case 3: case 5: case 7: diff --git a/bacnet-stack/include/mydata.h b/bacnet-stack/include/mydata.h index 1c35ea36..4cbdebed 100644 --- a/bacnet-stack/include/mydata.h +++ b/bacnet-stack/include/mydata.h @@ -17,7 +17,7 @@ typedef struct MyData { uint8_t cMyByte1; uint8_t cMyByte2; float fMyReal; - int8_t sMyString[MY_MAX_STR+1]; // A little extra for the nul + int8_t sMyString[MY_MAX_STR+1]; /* A little extra for the nul */ } DATABLOCK;