- extended file service and mms_utility
This commit is contained in:
parent
ecf64277a8
commit
374bfa03d4
4 changed files with 66 additions and 3 deletions
|
@ -19,6 +19,7 @@ print_help()
|
|||
printf("-r <variable_name> read domain variable\n");
|
||||
printf("-a <domain_name> specify domain for read or write command\n");
|
||||
printf("-f show file list\n");
|
||||
printf("-g <filename> get file attributes\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -31,6 +32,18 @@ mmsFileDirectoryHandler (void* parameter, char* filename, uint32_t size, uint64_
|
|||
printf("%s\n", filename);
|
||||
}
|
||||
|
||||
static void
|
||||
mmsGetFileAttributeHandler (void* parameter, char* filename, uint32_t size, uint64_t lastModified)
|
||||
{
|
||||
char gtString[30];
|
||||
Conversions_msTimeToGeneralizedTime(lastModified, (uint8_t*) gtString);
|
||||
|
||||
printf("FILENAME: %s\n", filename);
|
||||
printf("SIZE: %u\n", size);
|
||||
printf("DATE: %s\n", gtString);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
char* hostname = copyString("localhost");
|
||||
|
@ -39,6 +52,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
char* domainName = NULL;
|
||||
char* variableName = NULL;
|
||||
char* filename = NULL;
|
||||
|
||||
int readDeviceList = 0;
|
||||
int getDeviceDirectory = 0;
|
||||
|
@ -46,11 +60,12 @@ int main(int argc, char** argv) {
|
|||
int readWriteHasDomain = 0;
|
||||
int readVariable = 0;
|
||||
int showFileList = 0;
|
||||
int getFileAttributes = 0;
|
||||
|
||||
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "ifdh:p:l:t:a:r:")) != -1)
|
||||
while ((c = getopt(argc, argv, "ifdh:p:l:t:a:r:g:")) != -1)
|
||||
switch (c) {
|
||||
case 'h':
|
||||
hostname = copyString(optarg);
|
||||
|
@ -82,6 +97,10 @@ int main(int argc, char** argv) {
|
|||
case 'f':
|
||||
showFileList = 1;
|
||||
break;
|
||||
case 'g':
|
||||
getFileAttributes = 1;
|
||||
filename = copyString(optarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
print_help();
|
||||
|
@ -177,6 +196,10 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (getFileAttributes) {
|
||||
MmsConnection_getFileDirectory(con, &error, filename, NULL, mmsGetFileAttributeHandler, NULL);
|
||||
}
|
||||
|
||||
exit:
|
||||
MmsConnection_destroy(con);
|
||||
}
|
||||
|
|
|
@ -509,6 +509,39 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire
|
|||
|
||||
FileSystem_closeDirectory(directory);
|
||||
}
|
||||
else if (directoryName != NULL) {
|
||||
uint64_t msTime;
|
||||
|
||||
uint32_t fileSize;
|
||||
|
||||
if (FileSystem_getFileInfo(directoryName, &fileSize, &msTime)) {
|
||||
|
||||
char gtString[30];
|
||||
|
||||
Conversions_msTimeToGeneralizedTime(msTime, (uint8_t*) gtString);
|
||||
|
||||
int fileAttributesSize = encodeFileAttributes(0xa1, fileSize, gtString, NULL, 0);
|
||||
|
||||
int filenameSize = encodeFileSpecification(0xa0, directoryName, NULL, 0);
|
||||
|
||||
int dirEntrySize = 2 + fileAttributesSize + filenameSize;
|
||||
|
||||
int overallEntrySize = 1 + BerEncoder_determineLengthSize(dirEntrySize) + dirEntrySize;
|
||||
|
||||
int bufferSpaceLeft = maxBufSize - bufPos;
|
||||
|
||||
if (overallEntrySize <= bufferSpaceLeft) {
|
||||
bufPos = BerEncoder_encodeTL(0x30, dirEntrySize, buffer, bufPos); /* SEQUENCE (DirectoryEntry) */
|
||||
bufPos = encodeFileSpecification(0xa0, directoryName, buffer, bufPos); /* fileName */
|
||||
bufPos = encodeFileAttributes(0xa1, fileSize, gtString, buffer, bufPos); /* file attributes */
|
||||
}
|
||||
|
||||
else
|
||||
bufPos = -1;
|
||||
}
|
||||
else
|
||||
bufPos = -1;
|
||||
}
|
||||
else
|
||||
bufPos = -1;
|
||||
|
||||
|
|
|
@ -513,4 +513,8 @@ EXPORTS
|
|||
ClientSVControlBlock_getDstAddress
|
||||
ClientSVControlBlock_getOptFlds
|
||||
ClientSVControlBlock_getSmpMod
|
||||
ClientSVControlBlock_getNoASDU
|
||||
ClientSVControlBlock_getNoASDU
|
||||
CDC_CTE_create
|
||||
CDC_SPV_create
|
||||
CDC_TMS_create
|
||||
|
|
@ -563,4 +563,7 @@ EXPORTS
|
|||
ClientSVControlBlock_getDstAddress
|
||||
ClientSVControlBlock_getOptFlds
|
||||
ClientSVControlBlock_getSmpMod
|
||||
ClientSVControlBlock_getNoASDU
|
||||
ClientSVControlBlock_getNoASDU
|
||||
CDC_CTE_create
|
||||
CDC_SPV_create
|
||||
CDC_TMS_create
|
||||
|
|
Loading…
Add table
Reference in a new issue