Merge remote-tracking branch 'refs/remotes/mz-automation/master'

pull/11/head
yiqifeiyang 9 years ago
commit df6177b4c3

@ -1,5 +1,10 @@
Changes to version 1.0.1
------------------------
- server: fixed problem in COTP src/dst reference handling (returning zero src reference)
- client: fixed problem in report handling when RCB contains no rptID
- Python: added pyiec61850 tutorial and example thanks to Cédric Boudinet
- .NET API: fixed server side bug with connection indication handler
- added Lantronix XPORT PRO uclinux make target
- .NET API: fixed bug in client readValue functions
- .NET API: added MmsValue.GetDataAccessError() method

@ -79,10 +79,13 @@ set(API_HEADERS
src/hal/inc/hal_time.h
src/hal/inc/hal_thread.h
src/hal/inc/hal_filesystem.h
src/hal/inc/platform_endian.h
src/common/inc/libiec61850_common_api.h
src/common/inc/libiec61850_platform_includes.h
src/common/inc/linked_list.h
src/common/inc/byte_buffer.h
src/common/inc/lib_memory.h
src/common/inc/string_utilities.h
src/iec61850/inc/iec61850_client.h
src/iec61850/inc/iec61850_common.h
src/iec61850/inc/iec61850_server.h
@ -108,6 +111,7 @@ set(API_HEADERS
src/sampled_values/sv_subscriber.h
src/sampled_values/sv_publisher.h
src/logging/logging_api.h
${CMAKE_CURRENT_BINARY_DIR}/config/stack_config.h
)
IF(MSVC)

@ -24,6 +24,7 @@
#define DEBUG_GOOSE_SUBSCRIBER 0
#define DEBUG_GOOSE_PUBLISHER 0
#define DEBUG_SV_SUBSCRIBER 0
#define DEBUG_SV_PUBLISHER 0
#define DEBUG_HAL_ETHERNET 0
/* Maximum MMS PDU SIZE - default is 65000 */

@ -432,19 +432,26 @@ namespace IEC61850
IedConnection_destroy (connection);
}
}
}
private IsoConnectionParameters isoConnectionParameters = null;
/// <summary>
/// Gets the connection parameters
/// </summary>
/// <returns>The connection parameters</returns>
public IsoConnectionParameters GetConnectionParameters ()
{
IntPtr mmsConnection = IedConnection_getMmsConnection(connection);
IntPtr parameters = MmsConnection_getIsoConnectionParameters(mmsConnection);
return new IsoConnectionParameters(parameters);
{
if (isoConnectionParameters == null)
{
IntPtr mmsConnection = IedConnection_getMmsConnection(connection);
IntPtr parameters = MmsConnection_getIsoConnectionParameters(mmsConnection);
isoConnectionParameters = new IsoConnectionParameters(parameters);
}
return isoConnectionParameters;
}
private void FreeHGlobaleDeleteFunction (IntPtr pointer)

@ -102,8 +102,6 @@ namespace IEC61850
{
if (authParameter != IntPtr.Zero)
AcseAuthenticationParameter_destroy(authParameter);
//IsoConnectionParameters_destroy(self);
}
/// <summary>

@ -21,7 +21,6 @@ namespace authenticate
Console.WriteLine("Connect to " + hostname);
try
{
IsoConnectionParameters parameters = con.GetConnectionParameters();

@ -93,8 +93,6 @@ namespace reporting
rcb1.SetIntgPd(5000);
rcb1.SetRptEna(true);
rcb1.SetRCBValues();
rcb2.GetRCBValues();
if (rcb2.IsBuffered())

@ -29,7 +29,9 @@ gooseListener(GooseSubscriber subscriber, void* parameter)
printf(" stNum: %u sqNum: %u\n", GooseSubscriber_getStNum(subscriber),
GooseSubscriber_getSqNum(subscriber));
printf(" timeToLive: %u\n", GooseSubscriber_getTimeAllowedToLive(subscriber));
#ifndef _WIN32
printf(" timestamp: %"PRIu64"\n", GooseSubscriber_getTimestamp(subscriber));
#endif
MmsValue* values = GooseSubscriber_getDataSetValues(subscriber);

@ -65,8 +65,8 @@ int main(int argc, char** argv) {
if (error != IED_ERROR_OK)
printf("failed to write simpleIOGenericIO/GGIO1.NamPlt.vendor!\n");
else
MmsValue_delete(value);
MmsValue_delete(value);
/* read data set */
@ -117,6 +117,8 @@ int main(int argc, char** argv) {
ClientDataSet_destroy(clientDataSet);
ClientReportControlBlock_destroy(rcb);
close_connection:
IedConnection_close(con);

@ -42,8 +42,9 @@ printDataDirectory(char* doRef, IedConnection con, int spaces)
sprintf(daRef, "%s.%s", doRef, daName);
printDataDirectory(daRef, con, spaces + 2);
}
}
LinkedList_destroy(dataAttributes);
}
int
@ -145,6 +146,8 @@ main(int argc, char** argv)
dataSetMemberRef = LinkedList_getNext(dataSetMemberRef);
}
LinkedList_destroy(dataSetMembers);
dataSet = LinkedList_getNext(dataSet);
}

@ -14,8 +14,9 @@
#include "hal_thread.h"
int main(int argc, char** argv) {
int
main(int argc, char** argv)
{
char* hostname;
int tcpPort = 102;
@ -46,25 +47,22 @@ int main(int argc, char** argv) {
/* use this to skip AP-Title completely - this may be required by some "obscure" servers */
// IsoConnectionParameters_setRemoteApTitle(parameters, NULL, 0);
// IsoConnectionParameters_setLocalApTitle(parameters, NULL, 0);
TSelector localTSelector = { 3, { 0x00, 0x01, 0x02 } };
TSelector remoteTSelector = { 2, { 0x00, 0x01 } };
TSelector localTSelector = { 3, { 0x00, 0x01, 0x02 } };
TSelector remoteTSelector = { 2, { 0x00, 0x01 } };
SSelector sSelector1 = {2, { 0, 1 } };
SSelector sSelector2 = {5, { 0, 1, 2, 3, 4 } };
SSelector sSelector1 = { 2, { 0, 1 } };
SSelector sSelector2 = { 5, { 0, 1, 2, 3, 4 } };
/* change parameters for presentation, session and transport layers */
IsoConnectionParameters_setRemoteAddresses(parameters, 0x12345678, sSelector1, localTSelector);
IsoConnectionParameters_setLocalAddresses(parameters, 0x87654321, sSelector2 , remoteTSelector);
IsoConnectionParameters_setRemoteAddresses(parameters, 0x12345678, sSelector1, localTSelector);
IsoConnectionParameters_setLocalAddresses(parameters, 0x87654321, sSelector2, remoteTSelector);
char* password = "top secret";
/* use authentication */
AcseAuthenticationParameter auth = (AcseAuthenticationParameter) calloc(1, sizeof(struct sAcseAuthenticationParameter));
auth->mechanism = ACSE_AUTH_PASSWORD;
auth->value.password.octetString = (uint8_t*) password;
auth->value.password.passwordLength = strlen(password);
AcseAuthenticationParameter auth = AcseAuthenticationParameter_create();
AcseAuthenticationParameter_setAuthMechanism(auth, ACSE_AUTH_PASSWORD);
AcseAuthenticationParameter_setPassword(auth, password);
IsoConnectionParameters_setAcseAuthenticationParameter(parameters, auth);
@ -84,6 +82,8 @@ int main(int argc, char** argv) {
}
IedConnection_destroy(con);
AcseAuthenticationParameter_destroy(auth);
}

@ -53,10 +53,6 @@ int main(int argc, char** argv) {
IedConnection con = IedConnection_create();
MmsConnection mmsCon = IedConnection_getMmsConnection(con);
MmsConnection_setLocalDetail(mmsCon, 800);
IedConnection_connect(con, &error, hostname, tcpPort);
if (error == IED_ERROR_OK) {

@ -4,6 +4,7 @@
#include <unistd.h>
#include "string_utilities.h"
#include "mms_client_connection.h"
#include "conversions.h"
static void
print_help()
@ -351,6 +352,7 @@ int main(int argc, char** argv) {
}
exit:
free(hostname);
MmsConnection_destroy(con);
}

@ -87,9 +87,9 @@
<TrgOps dchg="true" qchg="true"/>
</LogControl>
<LogControl name="GeneralLog" datSet="" logName="">
<LogControl name="GeneralLog" logName="">
<TrgOps dchg="true" qchg="true"/>
</LogControl>
</LogControl>
<Log />

@ -1944,13 +1944,13 @@ extern ReportControlBlock iedModel_GenericIO_LLN0_report4;
extern ReportControlBlock iedModel_GenericIO_LLN0_report5;
extern ReportControlBlock iedModel_GenericIO_LLN0_report6;
ReportControlBlock iedModel_GenericIO_LLN0_report0 = {&iedModel_GenericIO_LLN0, "EventsRCB01", "Events1", false, "Events", 4294967295, 24, 111, 50, 1000, &iedModel_GenericIO_LLN0_report1};
ReportControlBlock iedModel_GenericIO_LLN0_report1 = {&iedModel_GenericIO_LLN0, "EventsIndexed01", "Events2", false, "Events", 1, 24, 111, 50, 1000, &iedModel_GenericIO_LLN0_report2};
ReportControlBlock iedModel_GenericIO_LLN0_report2 = {&iedModel_GenericIO_LLN0, "EventsIndexed02", "Events2", false, "Events", 1, 24, 111, 50, 1000, &iedModel_GenericIO_LLN0_report3};
ReportControlBlock iedModel_GenericIO_LLN0_report3 = {&iedModel_GenericIO_LLN0, "EventsIndexed03", "Events2", false, "Events", 1, 24, 111, 50, 1000, &iedModel_GenericIO_LLN0_report4};
ReportControlBlock iedModel_GenericIO_LLN0_report4 = {&iedModel_GenericIO_LLN0, "Measurements01", "Measurements", true, "Measurements", 1, 16, 111, 50, 1000, &iedModel_GenericIO_LLN0_report5};
ReportControlBlock iedModel_GenericIO_LLN0_report5 = {&iedModel_GenericIO_LLN0, "Measurements02", "Measurements", true, "Measurements", 1, 16, 111, 50, 1000, &iedModel_GenericIO_LLN0_report6};
ReportControlBlock iedModel_GenericIO_LLN0_report6 = {&iedModel_GenericIO_LLN0, "Measurements03", "Measurements", true, "Measurements", 1, 16, 111, 50, 1000, NULL};
ReportControlBlock iedModel_GenericIO_LLN0_report0 = {&iedModel_GenericIO_LLN0, "EventsRCB01", "Events1", false, "Events", 4294967295, 24, 239, 50, 1000, &iedModel_GenericIO_LLN0_report1};
ReportControlBlock iedModel_GenericIO_LLN0_report1 = {&iedModel_GenericIO_LLN0, "EventsIndexed01", "Events2", false, "Events", 1, 24, 239, 50, 1000, &iedModel_GenericIO_LLN0_report2};
ReportControlBlock iedModel_GenericIO_LLN0_report2 = {&iedModel_GenericIO_LLN0, "EventsIndexed02", "Events2", false, "Events", 1, 24, 239, 50, 1000, &iedModel_GenericIO_LLN0_report3};
ReportControlBlock iedModel_GenericIO_LLN0_report3 = {&iedModel_GenericIO_LLN0, "EventsIndexed03", "Events2", false, "Events", 1, 24, 239, 50, 1000, &iedModel_GenericIO_LLN0_report4};
ReportControlBlock iedModel_GenericIO_LLN0_report4 = {&iedModel_GenericIO_LLN0, "Measurements01", "Measurements", true, "Measurements", 1, 16, 239, 50, 1000, &iedModel_GenericIO_LLN0_report5};
ReportControlBlock iedModel_GenericIO_LLN0_report5 = {&iedModel_GenericIO_LLN0, "Measurements02", "Measurements", true, "Measurements", 1, 16, 239, 50, 1000, &iedModel_GenericIO_LLN0_report6};
ReportControlBlock iedModel_GenericIO_LLN0_report6 = {&iedModel_GenericIO_LLN0, "Measurements03", "Measurements", true, "Measurements", 1, 16, 239, 50, 1000, NULL};

@ -1,7 +1,7 @@
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs REQUIRED)
FIND_PACKAGE ( PythonInterp REQUIRED )
FIND_PACKAGE ( PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED )
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(CMAKE_SWIG_FLAGS "")

@ -55,20 +55,20 @@ def testClient():
theVal = "testmodelSENSORS/TTMP1.TmpSp.setMag.f"
theValType = iec61850.IEC61850_FC_SP
temperatureSetpoint = iec61850.IedConnection_readFloatValue(con, theVal, theValType)
print temperatureSetpoint
print(temperatureSetpoint)
assert(temperatureValue[1]==0)
newValue= temperatureValue[0]+10
err = iec61850.IedConnection_writeFloatValue(con, theVal, theValType, newValue)
assert(err==0)
temperatureSetpoint = iec61850.IedConnection_readFloatValue(con, theVal, theValType)
print temperatureSetpoint
print(temperatureSetpoint)
assert(temperatureSetpoint[0]==newValue)
iec61850.IedConnection_close(con)
else:
print "Connection error"
print("Connection error")
sys.exit(-1)
iec61850.IedConnection_destroy(con)
print "client ok"
print("client ok")
try:
srv=myIECServer()
srvThread = threading.Thread(target = srv.run)
@ -78,6 +78,6 @@ try:
#signal.pause()
except:
running = 0
print "Error :"
print("Error :")
traceback.print_exc(file=sys.stdout)
sys.exit(-1)

@ -15,7 +15,7 @@
#include "platform_endian.h"
#define LIBIEC61850_VERSION "1.0.0"
#define LIBIEC61850_VERSION "1.0.1"
#ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME
#define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com"

@ -359,11 +359,14 @@ private_IedConnection_handleReport(IedConnection self, MmsValue* value)
while (element != NULL) {
ClientReport report = (ClientReport) element->data;
char defaultRptId[129];
char* rptId = report->rptId;
if (rptId == NULL)
rptId = report->rcbReference;
if ((rptId == NULL) || (rptId && (strlen(rptId) == 0))) {
strncpy(defaultRptId, report->rcbReference, 129);
StringUtils_replace(defaultRptId, '.', '$');
rptId = defaultRptId;
}
if (strcmp(MmsValue_toString(rptIdValue), rptId) == 0) {
matchingReport = report;

@ -38,8 +38,8 @@ typedef struct {
typedef struct {
int state;
int srcRef;
int dstRef;
int remoteRef;
int localRef;
int protocolClass;
Socket socket;
CotpOptions options;
@ -97,9 +97,9 @@ ByteBuffer*
CotpConnection_getPayload(CotpConnection* self);
int
CotpConnection_getSrcRef(CotpConnection* self);
CotpConnection_getRemoteRef(CotpConnection* self);
int
CotpConnection_getDstRef(CotpConnection* self);
CotpConnection_getLocalRef(CotpConnection* self);
#endif /* COTP_H_ */

@ -123,10 +123,10 @@ writeStaticConnectResponseHeader(CotpConnection* self, int optionsLength)
buffer[4] = 6 + optionsLength;
buffer[5] = 0xd0;
buffer[6] = (uint8_t) (self->srcRef / 0x100);
buffer[7] = (uint8_t) (self->srcRef & 0xff);
buffer[8] = (uint8_t) (self->dstRef / 0x100);
buffer[9] = (uint8_t) (self->dstRef & 0xff);
buffer[6] = (uint8_t) (self->remoteRef / 0x100);
buffer[7] = (uint8_t) (self->remoteRef & 0xff);
buffer[8] = (uint8_t) (self->localRef / 0x100);
buffer[9] = (uint8_t) (self->localRef & 0xff);
buffer[10] = (uint8_t) (self->protocolClass);
self->writeBuffer->size = 11;
@ -312,8 +312,8 @@ CotpConnection_sendConnectionRequestMessage(CotpConnection* self, IsoConnectionP
buffer[7] = 0x00;
/* SRC REF */
buffer[8] = 0x00;
buffer[9] = 0x02; /* or 0x01 ? */
buffer[8] = (uint8_t) (self->localRef / 0x100);
buffer[9] = (uint8_t) (self->localRef & 0xff);
/* Class */
buffer[10] = 0x00;
@ -435,8 +435,8 @@ CotpConnection_init(CotpConnection* self, Socket socket,
{
self->state = 0;
self->socket = socket;
self->srcRef = -1;
self->dstRef = -1;
self->remoteRef = -1;
self->localRef = 1;
self->protocolClass = -1;
self->options.tpduSize = 0;
@ -487,15 +487,15 @@ CotpConnection_getPayload(CotpConnection* self)
}
int
CotpConnection_getSrcRef(CotpConnection* self)
CotpConnection_getRemoteRef(CotpConnection* self)
{
return self->srcRef;
return self->remoteRef;
}
int
CotpConnection_getDstRef(CotpConnection* self)
CotpConnection_getLocalRef(CotpConnection* self)
{
return self->dstRef;
return self->localRef;
}
/*
@ -515,8 +515,7 @@ parseConnectRequestTpdu(CotpConnection* self, uint8_t* buffer, uint8_t len)
if (len < 6)
return false;
self->dstRef = getUint16(buffer);
self->srcRef = getUint16(buffer + 2);
self->remoteRef = getUint16(buffer + 2);
self->protocolClass = getUint8(buffer + 4);
return parseOptions(self, buffer + 5, len - 6);
@ -528,8 +527,7 @@ parseConnectConfirmTpdu(CotpConnection* self, uint8_t* buffer, uint8_t len)
if (len < 6)
return false;
self->srcRef = getUint16(buffer);
self->dstRef = getUint16(buffer + 2);
self->remoteRef = getUint16(buffer);
self->protocolClass = getUint8(buffer + 4);
return parseOptions(self, buffer + 5, len - 6);

@ -1999,6 +1999,7 @@ MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize)
case MMS_STRUCTURE:
case MMS_ARRAY:
{
if (bufferSize==0) break;
buffer[0] = '{';
int bufPos = 1;

@ -134,7 +134,7 @@ createTypeSpecification (
break;
default:
if (DEBUG_MMS_SERVER)
printf("MMS-SERVER: Unsupported type %i!\n", namedVariable->type);
printf("MMS-SERVER: Unsupported type %i!\n", namedVariable->type);
return -1;
break;
}

@ -30,7 +30,9 @@
#include "hal_ethernet.h"
#include "ber_encoder.h"
#ifndef DEBUG_SV_PUBLISHER
#define DEBUG_SV_PUBLISHER 1
#endif
#define CONFIG_SV_DEFAULT_DST_ADDRESS CONFIG_GOOSE_DEFAULT_DST_ADDRESS
@ -567,6 +569,11 @@ SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value)
}
}
uint16_t
SV_ASDU_getSmpCnt(SV_ASDU self)
{
return self->smpCnt;
}
void
SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value)

@ -89,6 +89,9 @@ SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value);
void
SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value);
uint16_t
SV_ASDU_getSmpCnt(SV_ASDU self);
void
SV_ASDU_increaseSmpCnt(SV_ASDU self);

@ -90,11 +90,11 @@ public class OptionFields {
if (boolVal != null)
this.entryID = boolVal;
boolVal = ParserUtils.parseBooleanAttribute(optFieldsNode, "bufOvfl");
boolVal = ParserUtils.parseBooleanAttribute(optFieldsNode, "configRef");
if (boolVal != null)
this.configRef = boolVal;
boolVal = ParserUtils.parseBooleanAttribute(optFieldsNode, "reasonCode");
boolVal = ParserUtils.parseBooleanAttribute(optFieldsNode, "bufOvlf");
if (boolVal != null)
this.bufOvfl = boolVal;
}

Loading…
Cancel
Save