Chore/bacnet-sc-unrelated-cleanup (#620)
* Added required linux Ethernet library for ethernet build * Added .obj to gitignore * Fixed BACnet port for APPLE to use BSD in CMake * Changed format in CMake to enable cleaner SC merge * Added create-object and delete-object recipes in GCC Makefile * Added datalink timer to all example OS apps * Changed most microcontroller ports to use BACAPP_MINIMAL to specify which datatypes can be written. * Fixed zephyr OS for BACnet/IP warning * Fixed zephyr OS log to not require log_strdup * Added writefile API to file object example * Added API to device-client to make it more robust. * Added API in network-port object for getting the ASCII object-name * Added debug print with a timestamp option * Added debug print with hex dump print * Added API to network port object for activate and discard * Added default define for debug with timestamp * Added prototype in header for disabled debug printf. * Added fifo peek ahead function to peek at more than one byte. * Added get-mac value for network port that uses buffer rather than octetstring
This commit is contained in:
@@ -294,7 +294,7 @@ static long fsize(FILE *pFile)
|
||||
/**
|
||||
* @brief Read the entire file into a buffer
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param buffer - pointer to buffer pointer where heap data will be stored
|
||||
* @param buffer - data store from the file
|
||||
* @param buffer_size - in bytes
|
||||
* @return file size in bytes
|
||||
*/
|
||||
@@ -322,6 +322,35 @@ uint32_t bacfile_read(uint32_t object_instance, uint8_t *buffer,
|
||||
return (uint32_t)file_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write the entire file from a buffer
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param buffer - data store for the file
|
||||
* @param buffer_size - in bytes
|
||||
* @return file size in bytes
|
||||
*/
|
||||
uint32_t bacfile_write(uint32_t object_instance, uint8_t *buffer,
|
||||
uint32_t buffer_size)
|
||||
{
|
||||
const char *pFilename = NULL;
|
||||
FILE *pFile = NULL;
|
||||
long file_size = 0;
|
||||
|
||||
pFilename = bacfile_pathname(object_instance);
|
||||
if (pFilename) {
|
||||
/* open the file as a clean slate when starting at 0 */
|
||||
pFile = fopen(pFilename, "wb");
|
||||
if (pFile) {
|
||||
if (fwrite(buffer, buffer_size, 1, pFile) == 1) {
|
||||
file_size = buffer_size;
|
||||
}
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
|
||||
return (uint32_t)file_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines the file size for a given file
|
||||
* @param pFile - file handle
|
||||
@@ -1053,5 +1082,7 @@ void bacfile_cleanup(void)
|
||||
*/
|
||||
void bacfile_init(void)
|
||||
{
|
||||
Object_List = Keylist_Create();
|
||||
if (!Object_List) {
|
||||
Object_List = Keylist_Create();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user