Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Redefinitions. #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions GuruxDLMSServerExample/.vscode/settings.json
@@ -0,0 +1,12 @@
{
"makefile.launchConfigurations": [
{
"cwd": "/mnt/d/Work/GuruxDLMS.c/GuruxDLMSServerExample/bin",
"binaryPath": "/mnt/d/Work/GuruxDLMS.c/GuruxDLMSServerExample/bin/gurux.dlms.server.bin",
"binaryArgs": [
"-tVerbose",
"-p4059"
]
}
]
}
8 changes: 4 additions & 4 deletions GuruxDLMSServerExample/include/exampleserver.h
Expand Up @@ -22,11 +22,11 @@

#include "../../development/include/server.h"

#if defined(_WIN32) | defined(_WIN64) || defined(__linux__)
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)
#include "connection.h"
char DATAFILE[FILENAME_MAX];
char IMAGEFILE[FILENAME_MAX];
char TRACEFILE[FILENAME_MAX];
extern char DATAFILE[FILENAME_MAX];
extern char IMAGEFILE[FILENAME_MAX];
extern char TRACEFILE[FILENAME_MAX];
void println(char* desc, gxByteBuffer* data);

int svr_start(
Expand Down
50 changes: 25 additions & 25 deletions GuruxDLMSServerExample/src/exampleserver.c
Expand Up @@ -252,7 +252,7 @@ int saveSecurity(
}
else
{
printf("%s\r\n", "Failed to open keys file.");
printf("%s\n", "Failed to open keys file.");
}
return ret;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ int saveSettings()
}
else
{
printf("%s\r\n", "Failed to open settings file.");
printf("%s\n", "Failed to open settings file.");
}
return ret;
}
Expand Down Expand Up @@ -585,11 +585,11 @@ void GXTRACE(const char* str, const char* data)
{
if (data == NULL)
{
printf("%s\r\n", str);
printf("%s\n", str);
}
else
{
printf("%s %s\r\n", str, data);
printf("%s %s\n", str, data);
}
}
}
Expand Down Expand Up @@ -637,7 +637,7 @@ void println(char* desc, gxByteBuffer* data)
if (data != NULL)
{
char* str = bb_toHexString(data);
printf("%s: %s\r\n", desc, str);
printf("%s: %s\n", desc, str);
free(str);
}
}
Expand Down Expand Up @@ -676,7 +676,7 @@ int addAssociationLow()
//Only Logical Device Name is add to this Association View.
OA_ATTACH(associationLow.objectList, ALL_OBJECTS);
associationLow.authenticationMechanismName.mechanismId = DLMS_AUTHENTICATION_LOW;
associationLow.clientSAP = 0x11;
associationLow.clientSAP = 0x20;
associationLow.xDLMSContextInfo.maxSendPduSize = associationLow.xDLMSContextInfo.maxReceivePduSize = PDU_BUFFER_SIZE;
associationLow.xDLMSContextInfo.conformance = (DLMS_CONFORMANCE)(DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_ACTION |
DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_SET_OR_WRITE |
Expand Down Expand Up @@ -707,7 +707,7 @@ int addAssociationHigh()
associationHigh.authenticationMechanismName.mechanismId = DLMS_AUTHENTICATION_HIGH;
OA_ATTACH(associationHigh.objectList, ALL_OBJECTS);
BB_ATTACH(associationHigh.xDLMSContextInfo.cypheringInfo, CYPHERING_INFO, 0);
associationHigh.clientSAP = 0x12;
associationHigh.clientSAP = 0x30;
associationHigh.xDLMSContextInfo.maxSendPduSize = associationHigh.xDLMSContextInfo.maxReceivePduSize = PDU_BUFFER_SIZE;
associationHigh.xDLMSContextInfo.conformance = (DLMS_CONFORMANCE)(DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_ACTION |
DLMS_CONFORMANCE_BLOCK_TRANSFER_WITH_SET_OR_WRITE |
Expand Down Expand Up @@ -2411,13 +2411,13 @@ int readProfileGeneric(
#if _MSC_VER > 1400
if (fopen_s(&f, fileName, "rb") != 0)
{
printf("Failed to open %s.\r\n", fileName);
printf("Failed to open %s.\n", fileName);
return -1;
}
#else
if ((f = fopen(fileName, "rb")) != 0)
{
printf("Failed to open %s.\r\n", fileName);
printf("Failed to open %s.\n", fileName);
return -1;
}
#endif
Expand All @@ -2434,7 +2434,7 @@ int readProfileGeneric(
//Skip current index and total amount of the entries (+4 bytes).
if (fseek(f, 4 + ((e->transactionStartIndex - 1) * dataSize), SEEK_SET) != 0)
{
printf("Failed to seek %s.\r\n", fileName);
printf("Failed to seek %s.\n", fileName);
return -1;
}
for (pos = e->transactionStartIndex - 1; pos != e->transactionEndIndex; ++pos)
Expand Down Expand Up @@ -2500,7 +2500,7 @@ int readProfileGeneric(
}
else
{
printf("Failed to open %s.\r\n", fileName);
printf("Failed to open %s.\n", fileName);
return -1;
}
}
Expand Down Expand Up @@ -2590,7 +2590,7 @@ int printValues(variantArray* values)
return DLMS_ERROR_CODE_READ_WRITE_DENIED;
}
char* tmp = bb_toString(&bb);
printf("Writing %s\r\n", tmp);
printf("Writing %s\n", tmp);
free(tmp);
bb_clear(&bb);
}
Expand Down Expand Up @@ -2653,7 +2653,7 @@ void svr_preWrite(
e->handled = 1;
}
hlp_getLogicalNameToString(e->target->logicalName, str);
printf("Writing %s\r\n", str);
printf("Writing %s\n", str);
}
#endif //defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
}
Expand Down Expand Up @@ -2800,11 +2800,11 @@ void svr_preAction(
//Disconnect. Turn led OFF.
if (e->index == 1)
{
printf("%s\r\n", "Led is OFF.");
printf("%s\n", "Led is OFF.");
}
else //Reconnnect. Turn LED ON.
{
printf("%s\r\n", "Led is ON.");
printf("%s\n", "Led is ON.");
}
}
else if (e->target == BASE(scriptTableActivateTestMode))
Expand Down Expand Up @@ -2848,7 +2848,7 @@ void svr_preAction(
}
info->identification.size = size;
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Updating image %s Size: %d\r\n", imageFile, info->size);
printf("Updating image %s Size: %d\n", imageFile, info->size);
#endif
allocateImageTransfer(imageFile, info->size);
ba_clear(&i->imageTransferredBlocksStatus);
Expand All @@ -2874,7 +2874,7 @@ void svr_preAction(
if (!f)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Unable to open file %s\r\n", imageFile);
printf("Unable to open file %s\n", imageFile);
#endif
e->error = DLMS_ERROR_CODE_HARDWARE_FAULT;
return;
Expand All @@ -2897,7 +2897,7 @@ void svr_preAction(
if (!f)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Unable to open file %s\r\n", imageFile);
printf("Unable to open file %s\n", imageFile);
#endif
e->error = DLMS_ERROR_CODE_HARDWARE_FAULT;
return;
Expand All @@ -2916,14 +2916,14 @@ void svr_preAction(
if (time(NULL) - imageActionStartTime < 5)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Image verification is on progress.\r\n");
printf("Image verification is on progress.\n");
#endif
e->error = DLMS_ERROR_CODE_TEMPORARY_FAILURE;
}
else
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Image is verificated.\r\n");
printf("Image is verificated.\n");
#endif
i->imageTransferStatus = DLMS_IMAGE_TRANSFER_STATUS_VERIFICATION_SUCCESSFUL;
imageActionStartTime = time(NULL);
Expand All @@ -2938,14 +2938,14 @@ void svr_preAction(
if (time(NULL) - imageActionStartTime < 5)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Image activation is on progress.\r\n");
printf("Image activation is on progress.\n");
#endif
e->error = DLMS_ERROR_CODE_TEMPORARY_FAILURE;
}
else
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Image is activated.\r\n");
printf("Image is activated.\n");
#endif
i->imageTransferStatus = DLMS_IMAGE_TRANSFER_STATUS_ACTIVATION_SUCCESSFUL;
imageActionStartTime = time(NULL);
Expand Down Expand Up @@ -3513,7 +3513,7 @@ DLMS_ACCESS_MODE getActivityCalendarAttributeAccess(
unsigned char index)
{
//Only Activate passive calendar date-time and passive calendar settings are writeble.
if (settings->authentication > DLMS_AUTHENTICATION_LOW && index > 5)
if (settings->authentication >= DLMS_AUTHENTICATION_LOW && index > 5)
{
return DLMS_ACCESS_MODE_READ_WRITE;
}
Expand Down Expand Up @@ -3627,7 +3627,7 @@ int svr_connected(
dlmsServerSettings* settings)
{
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__)//If Windows or Linux
printf("Connected %d.\r\n", settings->base.connected);
printf("Connected %d.\n", settings->base.connected);
#endif
#ifdef DLMS_ITALIAN_STANDARD
if (settings->base.clientAddress == 1)
Expand Down Expand Up @@ -3674,7 +3674,7 @@ int svr_invalidConnection(dlmsServerSettings* settings)
int svr_disconnected(
dlmsServerSettings* settings)
{
printf("Disconnected %d.\r\n", settings->base.connected);
printf("Disconnected %d.\n", settings->base.connected);
if (settings->base.cipher.security != 0 && (settings->base.connected & DLMS_CONNECTION_STATE_DLMS) != 0)
{
//Save Invocation counter value when connection is closed.
Expand Down
6 changes: 5 additions & 1 deletion GuruxDLMSServerExample/src/main.c
Expand Up @@ -61,6 +61,10 @@ unsigned char sn47pduBuff[PDU_BUFFER_SIZE];
unsigned char ln47frameBuff[WRAPPER_BUFFER_SIZE];
unsigned char ln47pduBuff[PDU_BUFFER_SIZE];

char DATAFILE[FILENAME_MAX];
char IMAGEFILE[FILENAME_MAX];
char TRACEFILE[FILENAME_MAX];

int startServers(int port, int trace)
{
int ret;
Expand Down Expand Up @@ -199,7 +203,7 @@ int startServers(int port, int trace)
}
}
#else
char ch = _getch();
char ch = getchar();
if (ch == '\n')
{
printf("Closing the server.\n");
Expand Down
2 changes: 1 addition & 1 deletion GuruxDLMSServerExample2/makefile
Expand Up @@ -8,7 +8,7 @@ CFLAGS = -std=gnu99 -Wall -I. -DGX_DLMS_MICROCONTROLLER -DDLMS_USE_EPOCH_TIME

LINKER = gcc -o

DLMS_SRCDIR = dlms/src
DLMS_SRCDIR = ../development/src
SRCDIR = src
OBJDIR = obj
BINDIR = bin
Expand Down
14 changes: 7 additions & 7 deletions GuruxDLMSServerExample2/src/main.c
Expand Up @@ -45,15 +45,15 @@
#include <errno.h>
#endif

#include "../dlms/include/dlmssettings.h"
#include "../dlms/include/variant.h"
#include "../dlms/include/cosem.h"
#include "../dlms/include/server.h"
#include "../../development/include/dlmssettings.h"
#include "../../development/include/variant.h"
#include "../../development/include/cosem.h"
#include "../../development/include/server.h"
//Add this if you want to send notify messages.
#include "../dlms/include/notify.h"
#include "../../development/include/notify.h"
//Add support for serialization.
#include "../dlms/include/gxserializer.h"
#include "../dlms/include/gxset.h"
#include "../../development/include/gxserializer.h"
#include "../../development/include/gxset.h"

//Serial port handlers.
#if defined(_WIN32) || defined(_WIN64)// If Windows
Expand Down