Skip to content

Commit

Permalink
- fixed beaglebone demo
Browse files Browse the repository at this point in the history
- fixed bug in server side SBO control: checkHandler received different handles for same client connection
  • Loading branch information
Michael Zillgith committed Jun 4, 2015
1 parent a603b7a commit eb47693
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 209 deletions.
25 changes: 14 additions & 11 deletions demos/beaglebone/beagle_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ void sigint_handler(int signalId)
running = 0;
}

void
static void
connectionIndicationHandler(IedServer server, ClientConnection connection, bool connected, void* parameter)
{
char* clientAddress = ClientConnection_getPeerAddress(connection);
const char* clientAddress = ClientConnection_getPeerAddress(connection);

if (connected) {
printf("BeagleDemoServer: new client connection from %s\n", clientAddress);
Expand All @@ -62,14 +62,20 @@ performCheckHandler(void* parameter, MmsValue* ctlVal, bool test, bool interlock
automaticOperationMode = false;
}

/* test command not accepted if mode is "on" */
if (test)
return CONTROL_TEMPORARILY_UNAVAILABLE;

printf("controllingClient: %p connection: %p\n", controllingClient, connection);

/* If there is already another client that controls the device reject the control attempt */
if (controllingClient == connection)
return CONTROL_ACCEPTED;
else
return CONTROL_TEMPORARILY_UNAVAILABLE;
}

void
static void
updateLED1stVal(bool newLedState, uint64_t timeStamp) {
switchLED(LED1, newLedState);

Expand All @@ -78,7 +84,7 @@ updateLED1stVal(bool newLedState, uint64_t timeStamp) {
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1_t, timeStamp);
}

void
static void
updateLED2stVal(bool newLedState, uint64_t timeStamp) {
switchLED(LED2, newLedState);

Expand All @@ -87,7 +93,7 @@ updateLED2stVal(bool newLedState, uint64_t timeStamp) {
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO2_t, timeStamp);
}

void
static void
updateLED3stVal(bool newLedState, uint64_t timeStamp) {
switchLED(LED3, newLedState);

Expand All @@ -96,14 +102,11 @@ updateLED3stVal(bool newLedState, uint64_t timeStamp) {
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO3_t, timeStamp);
}

bool
static ControlHandlerResult
controlHandlerForBinaryOutput(void* parameter, MmsValue* value, bool test)
{
if (test)
return true;

if (MmsValue_getType(value) != MMS_BOOLEAN)
return false;
return CONTROL_RESULT_OK;

uint64_t timeStamp = Hal_getTimeInMs();

Expand Down Expand Up @@ -142,7 +145,7 @@ controlHandlerForBinaryOutput(void* parameter, MmsValue* value, bool test)
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_DPCSO1_t, timeStamp);
}

return true;
return CONTROL_RESULT_OK;
}


Expand Down
62 changes: 41 additions & 21 deletions demos/beaglebone/beagle_demo.icd
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,58 @@
</SubNetwork>
</Communication>
<IED name="beagle">

<Services>
<DynAssociation />
<GetDirectory />
<GetDataObjectDefinition />
<GetDataSetValue />
<DataSetDirectory />
<ReadWrite />
<GetCBValues />
<ConfLNs fixPrefix="true" fixLnInst="true" />
<GOOSE max="5" />
<GSSE max="5" />
<FileHandling />
<GSEDir />
<TimerActivatedControl />
<DynAssociation max="5"/>
<GetDirectory />
<DataObjectDirectory />
<GetDataObjectDefinition />
<GetDataSetValue />
<DataSetDirectory />
<ReadWrite />
<GetCBValues />
<ConfDataSet max="1" modify="false" />
<DynDataSet max="10"/>
<ConfReportControl max="1" bufConf="false" />
<ReportSettings cbName="Fix" datSet="Dyn" rptID="Dyn" optFields="Dyn" bufTime="Dyn" trgOps="Dyn" intgPd="Dyn" owner="true"/>
<ConfLNs fixPrefix="true" fixLnInst="true"/>
<ClientServices >
<TimeSyncProt sntp="true" c37_238="false" other="false"/>
</ClientServices>
<GOOSE max="5" />
<GSSE max="5" />
<GSEDir />
<TimerActivatedControl />
</Services>

<AccessPoint name="accessPoint1">
<Server>
<Authentication />
<LDevice inst="GenericIO">

<LN0 lnClass="LLN0" lnType="LLN01" inst="">

<DataSet name="Events" desc="Events">
<FCDA ldInst="GenericIO" lnClass="GGIO" fc="ST" lnInst="1" doName="SPCSO1" daName="stVal" />
<FCDA ldInst="GenericIO" lnClass="GGIO" fc="ST" lnInst="1" doName="SPCSO2" daName="stVal" />
<FCDA ldInst="GenericIO" lnClass="GGIO" fc="ST" lnInst="1" doName="SPCSO3" daName="stVal" />
<FCDA ldInst="GenericIO" lnClass="GGIO" fc="ST" lnInst="1" doName="DPCSO1" daName="stVal" />
</DataSet>
<ReportControl name="EventsRCB" confRev="1" datSet="Events" rptID="Events1" buffered="false" intgPd="1000" bufTime="50">
<TrgOps period="true" />
<OptFields seqNum="true" timeStamp="true" dataSet="true" reasonCode="true" entryID="true" configRef="true" />
<RptEnabled max="1" />
</ReportControl>

<ReportControl name="EventsRCB2" confRev="1" datSet="Events" rptID="Events2" buffered="false" intgPd="1000" bufTime="50">
<ReportControl name="EventsRCB" confRev="1" datSet="Events" rptID="Events1" buffered="false" intgPd="1000" bufTime="50">
<TrgOps period="true" />
<OptFields seqNum="true" timeStamp="true" dataSet="true" reasonCode="true" entryID="true" configRef="true" />
<RptEnabled max="1" />
<RptEnabled max="5" />
</ReportControl>

<DOI name="Mod">
<DAI name="ctlModel">
<Val>status-only</Val>
</DAI>
</DOI>

</LN0>

<LN lnClass="LPHD" lnType="LPHD1" inst="1" prefix="" />
<LN lnClass="GGIO" lnType="GGIO1" inst="1" prefix="">
<DOI name="Mod">
Expand All @@ -77,7 +85,7 @@
</DOI>
<DOI name="SPCSO2">
<DAI name="ctlModel">
<Val>direct-with-normal-security</Val>
<Val>sbo-with-normal-security</Val>
</DAI>
</DOI>
<DOI name="SPCSO3">
Expand All @@ -95,6 +103,7 @@
</Server>
</AccessPoint>
</IED>

<DataTypeTemplates>
<LNodeType id="LLN01" lnClass="LLN0">
<DO name="Mod" type="INC_1_Mod" />
Expand Down Expand Up @@ -183,7 +192,9 @@
<DOType id="SPC_1_SPCSO2" cdc="SPC">
<DA name="stVal" bType="BOOLEAN" fc="ST" dchg="true" />
<DA name="q" bType="Quality" fc="ST" qchg="true" />
<DA name="SBO" fc="CO" bType="VisString64" />
<DA name="Oper" type="SPCOperate_1" bType="Struct" fc="CO" />
<DA name="Cancel" fc="CO" bType="Struct" type="SPCCancel" />
<DA name="ctlModel" type="CtlModels" bType="Enum" fc="CF" />
<DA name="t" bType="Timestamp" fc="ST" />
</DOType>
Expand All @@ -209,6 +220,15 @@
<BDA name="Test" bType="BOOLEAN" />
<BDA name="Check" bType="Check" />
</DAType>

<DAType id="SPCCancel">
<BDA name="ctlVal" bType="INT8" />
<BDA name="origin" bType="Struct" type="Originator_1" />
<BDA name="ctlNum" bType="INT8U" />
<BDA name="T" bType="Timestamp" />
<BDA name="Test" bType="BOOLEAN" />
</DAType>

<EnumType id="CtlModels">
<EnumVal ord="0">status-only</EnumVal>
<EnumVal ord="1">direct-with-normal-security</EnumVal>
Expand Down
6 changes: 4 additions & 2 deletions demos/beaglebone/beaglebone_leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include <stdio.h>
#include "beaglebone_leds.h"

#ifndef SIMULATED
static void
writeToFile(char* filename, char* text)
{
FILE* file = fopen(filename, "w");
fprintf(file, text);
fprintf(file, "%s", text);
fclose(file);
}
#endif /* SIMULATED */

void
flashLED(char* led)
Expand All @@ -37,7 +39,7 @@ switchLED(char* led, int value)
{
#ifndef SIMULATED
char filename[255];
char* valueStr[10];
char valueStr[10];

sprintf(filename, "%s/trigger", led);
writeToFile(filename, "none");
Expand Down
2 changes: 1 addition & 1 deletion demos/beaglebone/beaglebone_leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define BEAGLEBONE_LEDS_H_


//#define SIMULATED 1
#define SIMULATED 1


#if 0
Expand Down
Loading

0 comments on commit eb47693

Please sign in to comment.